Refactor title update logic in App.tsx

This commit is contained in:
2026-01-31 18:54:10 +01:00
parent 131ef453a6
commit 15e61635a9

View File

@@ -947,19 +947,11 @@ export default function App() {
const applyTitleUpdate = useCallback((promptId: string, nextTitle: string) => { const applyTitleUpdate = useCallback((promptId: string, nextTitle: string) => {
const now = Date.now(); const now = Date.now();
setTexts((prev) => { setTexts((prev) =>
let updated: Text | null = null; prev.map((text) =>
const remaining: Text[] = []; text.id === promptId ? { ...text, title: nextTitle, updated_at: now } : text
for (const text of prev) { )
if (text.id === promptId) { );
updated = { ...text, title: nextTitle, updated_at: now };
} else {
remaining.push(text);
}
}
if (!updated) return prev;
return [updated, ...remaining];
});
}, []); }, []);
const handleTitleChange = useCallback( const handleTitleChange = useCallback(