fix: sync sidebar notebook counts after note creation
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 39s
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:
@@ -63,7 +63,7 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) {
|
|||||||
const [isLoading, setIsLoading] = useState(false) // false by default — data is pre-loaded
|
const [isLoading, setIsLoading] = useState(false) // false by default — data is pre-loaded
|
||||||
const [notebookSuggestion, setNotebookSuggestion] = useState<{ noteId: string; content: string } | null>(null)
|
const [notebookSuggestion, setNotebookSuggestion] = useState<{ noteId: string; content: string } | null>(null)
|
||||||
const [batchOrganizationOpen, setBatchOrganizationOpen] = useState(false)
|
const [batchOrganizationOpen, setBatchOrganizationOpen] = useState(false)
|
||||||
const { refreshKey } = useNoteRefresh()
|
const { refreshKey, triggerRefresh } = useNoteRefresh()
|
||||||
const { labels } = useLabels()
|
const { labels } = useLabels()
|
||||||
const { setControls } = useHomeView()
|
const { setControls } = useHomeView()
|
||||||
|
|
||||||
@@ -118,13 +118,15 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
triggerRefresh()
|
||||||
|
|
||||||
if (!note.notebookId) {
|
if (!note.notebookId) {
|
||||||
const wordCount = (note.content || '').trim().split(/\s+/).filter(w => w.length > 0).length
|
const wordCount = (note.content || '').trim().split(/\s+/).filter(w => w.length > 0).length
|
||||||
if (wordCount >= 20) {
|
if (wordCount >= 20) {
|
||||||
setNotebookSuggestion({ noteId: note.id, content: note.content || '' })
|
setNotebookSuggestion({ noteId: note.id, content: note.content || '' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [searchParams, labels, router])
|
}, [searchParams, labels, router, triggerRefresh])
|
||||||
|
|
||||||
const handleOpenNote = (noteId: string) => {
|
const handleOpenNote = (noteId: string) => {
|
||||||
const note = notes.find(n => n.id === noteId)
|
const note = notes.find(n => n.id === noteId)
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ export function NotesTabsView({ notes, onEdit, currentNotebookId }: NotesTabsVie
|
|||||||
if (!newNote) return
|
if (!newNote) return
|
||||||
setItems((prev) => [newNote, ...prev])
|
setItems((prev) => [newNote, ...prev])
|
||||||
setSelectedId(newNote.id)
|
setSelectedId(newNote.id)
|
||||||
|
triggerRefresh()
|
||||||
} catch {
|
} catch {
|
||||||
toast.error(t('notes.createFailed') || 'Impossible de créer la note')
|
toast.error(t('notes.createFailed') || 'Impossible de créer la note')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user