fix: sync sidebar notebook counts after note creation
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 39s

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 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 09:45:30 +02:00
parent e76572ccd5
commit e83f1d1e52
2 changed files with 5 additions and 2 deletions

View File

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

View File

@@ -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')
}