From e83f1d1e52681186eb1c0a003543f59277ded967 Mon Sep 17 00:00:00 2001 From: sepehr Date: Sun, 26 Apr 2026 09:45:30 +0200 Subject: [PATCH] fix: sync sidebar notebook counts after note creation Add triggerRefresh() call after note creation in both masonry (home-client) and tabs (notes-tabs-view) modes so NotebooksContext reloads notebook counts. Co-Authored-By: Claude Opus 4.7 --- memento-note/components/home-client.tsx | 6 ++++-- memento-note/components/notes-tabs-view.tsx | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/memento-note/components/home-client.tsx b/memento-note/components/home-client.tsx index 5f06f99..05b5edb 100644 --- a/memento-note/components/home-client.tsx +++ b/memento-note/components/home-client.tsx @@ -63,7 +63,7 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) { const [isLoading, setIsLoading] = useState(false) // false by default — data is pre-loaded const [notebookSuggestion, setNotebookSuggestion] = useState<{ noteId: string; content: string } | null>(null) const [batchOrganizationOpen, setBatchOrganizationOpen] = useState(false) - const { refreshKey } = useNoteRefresh() + const { refreshKey, triggerRefresh } = useNoteRefresh() const { labels } = useLabels() const { setControls } = useHomeView() @@ -118,13 +118,15 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) { } }) + triggerRefresh() + if (!note.notebookId) { const wordCount = (note.content || '').trim().split(/\s+/).filter(w => w.length > 0).length if (wordCount >= 20) { setNotebookSuggestion({ noteId: note.id, content: note.content || '' }) } } - }, [searchParams, labels, router]) + }, [searchParams, labels, router, triggerRefresh]) const handleOpenNote = (noteId: string) => { const note = notes.find(n => n.id === noteId) diff --git a/memento-note/components/notes-tabs-view.tsx b/memento-note/components/notes-tabs-view.tsx index eb06f09..c1502be 100644 --- a/memento-note/components/notes-tabs-view.tsx +++ b/memento-note/components/notes-tabs-view.tsx @@ -352,6 +352,7 @@ export function NotesTabsView({ notes, onEdit, currentNotebookId }: NotesTabsVie if (!newNote) return setItems((prev) => [newNote, ...prev]) setSelectedId(newNote.id) + triggerRefresh() } catch { toast.error(t('notes.createFailed') || 'Impossible de créer la note') }