fix: home-client écoute NOTE_CHANGE_EVENT — versioning indicator visible
Some checks failed
CI / Deploy production (on server) (push) Has been cancelled
CI / Lint, Unit Tests & Build (push) Has been cancelled

Root cause: home-client.tsx n'écoutait PAS NOTE_CHANGE_EVENT.
Quand versioning était activé depuis l'éditeur, emitNoteChange était dispatché
mais personne ne mettait à jour la liste des notes → historyEnabled restait false
sur les cartes/liste.

Fix: useEffect qui écoute NOTE_CHANGE_EVENT et patch les notes + pinnedNotes
avec les champs mis à jour (historyEnabled, etc.).
This commit is contained in:
Antigravity
2026-07-04 20:56:51 +00:00
parent 6b44d35c40
commit a7e3646ae6

View File

@@ -21,7 +21,7 @@ import {
import { NotebookSuggestionToast } from '@/components/notebook-suggestion-toast'
import { Button } from '@/components/ui/button'
import { Plus, ArrowUpDown, Search, Sparkles, FileText, FolderOpen, ChevronRight, ChevronDown, Tag as TagIcon, X, Menu, LayoutGrid, List, Table, Columns3, CalendarDays, Wand2, Download, Upload, Globe } from 'lucide-react'
import { emitNoteChange } from '@/lib/note-change-sync'
import { emitNoteChange, NOTE_CHANGE_EVENT, type NoteChangeEvent } from '@/lib/note-change-sync'
import { useReminderCheck } from '@/hooks/use-reminder-check'
import { useAutoLabelSuggestion } from '@/hooks/use-auto-label-suggestion'
import { useNotebooks } from '@/context/notebooks-context'
@@ -611,6 +611,20 @@ export function HomeClient({
})
}, [patchNoteInList])
// Écoute les mutations externes (versioning activé depuis éditeur, etc.)
useEffect(() => {
const onNoteChange = (e: Event) => {
const detail = (e as CustomEvent<NoteChangeEvent>).detail
if (!detail) return
if (detail.type === 'updated') {
patchNoteInList(detail.note.id, detail.note)
setPinnedNotes(prev => prev.map(n => n.id === detail.note.id ? { ...n, ...detail.note } : n))
}
}
window.addEventListener(NOTE_CHANGE_EVENT, onNoteChange)
return () => window.removeEventListener(NOTE_CHANGE_EVENT, onNoteChange)
}, [patchNoteInList])
const handleGridReorder = useCallback(
async (orderedIds: string[]) => {
setSortOrder('manual')