diff --git a/memento-note/components/home-client.tsx b/memento-note/components/home-client.tsx index 55ed711..edcb0db 100644 --- a/memento-note/components/home-client.tsx +++ b/memento-note/components/home-client.tsx @@ -149,6 +149,7 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) { setNotes((prev) => prev.map((n) => (n.id === noteId ? { ...n, historyEnabled: true } : n))) setPinnedNotes((prev) => prev.map((n) => (n.id === noteId ? { ...n, historyEnabled: true } : n))) setEditingNote((prev) => (prev?.note.id === noteId ? { ...prev, note: { ...prev.note, historyEnabled: true } } : prev)) + setHistoryNote((prev) => (prev?.id === noteId ? { ...prev, historyEnabled: true } : prev)) }, []) const handleHistoryRestored = useCallback((restored: Note) => { diff --git a/memento-note/components/note-history-modal.tsx b/memento-note/components/note-history-modal.tsx index 0df290a..d1601a6 100644 --- a/memento-note/components/note-history-modal.tsx +++ b/memento-note/components/note-history-modal.tsx @@ -4,7 +4,7 @@ import { useEffect, useMemo, useState, useTransition } from 'react' import { formatDistanceToNow } from 'date-fns' import { fr } from 'date-fns/locale/fr' import { enUS } from 'date-fns/locale/en-US' -import { History, Loader2, RotateCcw, Trash2, GitBranchPlus } from 'lucide-react' +import { History, Loader2, RotateCcw, Trash2, GitBranchPlus, Check } from 'lucide-react' import { toast } from 'sonner' import { getNoteHistory, restoreNoteVersion, deleteNoteHistoryEntry } from '@/app/actions/notes' import { Button } from '@/components/ui/button' @@ -48,6 +48,7 @@ export function NoteHistoryModal({ const [isLoading, setIsLoading] = useState(false) const [isRestoring, startRestoring] = useTransition() const [isEnabling, startEnabling] = useTransition() + const [justEnabled, setJustEnabled] = useState(false) useEffect(() => { if (!open || !note || !enabled) return @@ -96,6 +97,7 @@ export function NoteHistoryModal({ startEnabling(async () => { try { await onEnableHistory() + setJustEnabled(true) toast.success(t('notes.historyEnabled') || 'History activé') } catch (error) { console.error('Failed to enable history:', error) @@ -104,6 +106,12 @@ export function NoteHistoryModal({ }) } + useEffect(() => { + if (!justEnabled) return + const timer = setTimeout(() => setJustEnabled(false), 1800) + return () => clearTimeout(timer) + }, [justEnabled]) + const handleDeleteEntry = (entryId: string) => { if (!note) return if (!confirm(t('notes.deleteVersionConfirm') || 'Supprimer cette version définitivement ?')) return @@ -135,21 +143,37 @@ export function NoteHistoryModal({ - {!enabled ? ( + {!enabled || justEnabled ? (
- {t('notes.historyDisabledDesc') || "Suivez les modifications de cette note au fil du temps. Activez l'historique pour commencer à enregistrer des versions."} -
- + {justEnabled ? ( + <> ++ {t('notes.historyEnabledDesc') || "Les versions de cette note seront désormais enregistrées."} +
+ > + ) : ( + <> ++ {t('notes.historyDisabledDesc') || "Suivez les modifications de cette note au fil du temps. Activez l'historique pour commencer à enregistrer des versions."} +
+ + > + )}