diff --git a/memento-note/components/home-client.tsx b/memento-note/components/home-client.tsx index e1763a9..ec096f8 100644 --- a/memento-note/components/home-client.tsx +++ b/memento-note/components/home-client.tsx @@ -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).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')