Fix notes refresh (#572)

* Update notes on global creation

* fixup! Update notes on global creation
This commit is contained in:
Chris 2025-11-18 12:25:54 +02:00 committed by GitHub
parent 8c37446757
commit c21c505440
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);