From c21c505440933f9e933b6d8d85d2b5882fdc7340 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 18 Nov 2025 12:25:54 +0200 Subject: [PATCH] Fix notes refresh (#572) * Update notes on global creation * fixup! Update notes on global creation --- .../components/Project/ProjectDetails.tsx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/frontend/components/Project/ProjectDetails.tsx b/frontend/components/Project/ProjectDetails.tsx index 5c3f789..1a84b83 100644 --- a/frontend/components/Project/ProjectDetails.tsx +++ b/frontend/components/Project/ProjectDetails.tsx @@ -581,6 +581,16 @@ const ProjectDetails: React.FC = () => { return currentIdentifier !== noteIdentifier; }) ); + // Remove note from global store + const globalNotes = useStore.getState().notesStore.notes; + useStore.getState().notesStore.setNotes( + globalNotes.filter((note) => { + const currentIdentifier = + note.uid ?? + (note.id !== undefined ? String(note.id) : undefined); + return currentIdentifier !== noteIdentifier; + }) + ); setNoteToDelete(null); setIsConfirmDialogOpen(false); } catch { @@ -617,6 +627,15 @@ const ProjectDetails: React.FC = () => { if (savedNote.id && savedNoteProjectId !== currentProjectId) { setNotes(notes.filter((n) => n.id !== savedNote.id)); + // Update global store - update or remove note + const globalNotes = useStore.getState().notesStore.notes; + useStore + .getState() + .notesStore.setNotes( + globalNotes.map((note) => + note.uid === savedNote.uid ? savedNote : note + ) + ); } else if (isUpdate) { const savedIdentifier = savedNote.uid ?? @@ -633,8 +652,22 @@ const ProjectDetails: React.FC = () => { : n; }) ); + // Update global store + const globalNotes = useStore.getState().notesStore.notes; + useStore + .getState() + .notesStore.setNotes( + globalNotes.map((note) => + note.uid === savedNote.uid ? savedNote : note + ) + ); } else { setNotes([savedNote, ...notes]); + // Add new note to global store + const globalNotes = useStore.getState().notesStore.notes; + useStore + .getState() + .notesStore.setNotes([savedNote, ...globalNotes]); } setIsNoteModalOpen(false);