fix: suppression indicateur save redondant dans toolbar (existait déjà)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useState, useRef, useCallback, useEffect } from 'react'
|
import { useState, useRef, useCallback } from 'react'
|
||||||
import { useNoteEditorContext } from './note-editor-context'
|
import { useNoteEditorContext } from './note-editor-context'
|
||||||
import { LabelManager } from '@/components/label-manager'
|
import { LabelManager } from '@/components/label-manager'
|
||||||
import { LabelBadge } from '@/components/label-badge'
|
import { LabelBadge } from '@/components/label-badge'
|
||||||
@@ -46,22 +46,6 @@ export function NoteEditorToolbar({ mode, onClose, onToggleAttachments, attachme
|
|||||||
const [isConverting, setIsConverting] = useState(false)
|
const [isConverting, setIsConverting] = useState(false)
|
||||||
const [shareOpen, setShareOpen] = useState(false)
|
const [shareOpen, setShareOpen] = useState(false)
|
||||||
const [flashcardsOpen, setFlashcardsOpen] = useState(false)
|
const [flashcardsOpen, setFlashcardsOpen] = useState(false)
|
||||||
const [relativeTime, setRelativeTime] = useState<string | null>(null)
|
|
||||||
|
|
||||||
// Mise à jour du temps relatif depuis la dernière sauvegarde
|
|
||||||
useEffect(() => {
|
|
||||||
if (!state.lastSavedAt) { setRelativeTime(null); return }
|
|
||||||
const update = () => {
|
|
||||||
const secs = Math.floor((Date.now() - state.lastSavedAt!.getTime()) / 1000)
|
|
||||||
if (secs < 10) setRelativeTime(t('notes.savedJustNow') || 'Sauvegardé')
|
|
||||||
else if (secs < 60) setRelativeTime(`${secs}s`)
|
|
||||||
else setRelativeTime(`${Math.floor(secs / 60)}min`)
|
|
||||||
}
|
|
||||||
update()
|
|
||||||
const interval = setInterval(update, 10000)
|
|
||||||
return () => clearInterval(interval)
|
|
||||||
}, [state.lastSavedAt, t])
|
|
||||||
|
|
||||||
const notebookName = notebooks.find(nb => nb.id === note.notebookId)?.name || null
|
const notebookName = notebooks.find(nb => nb.id === note.notebookId)?.name || null
|
||||||
|
|
||||||
const undoSnapshotRef = useRef<{ content: string; isMarkdown: boolean } | null>(null)
|
const undoSnapshotRef = useRef<{ content: string; isMarkdown: boolean } | null>(null)
|
||||||
@@ -310,18 +294,6 @@ export function NoteEditorToolbar({ mode, onClose, onToggleAttachments, attachme
|
|||||||
|
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
{/* Indicateur dernière sauvegarde */}
|
|
||||||
{!state.isDirty && relativeTime && !state.isSaving && (
|
|
||||||
<span className="hidden sm:flex items-center gap-1 text-[10px] text-concrete/70 font-medium select-none">
|
|
||||||
<Check size={10} className="text-emerald-500" />
|
|
||||||
{relativeTime}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{state.isDirty && !state.isSaving && (
|
|
||||||
<span className="hidden sm:block text-[10px] text-amber-500 font-medium select-none">
|
|
||||||
{t('notes.unsaved') || '●'}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<button
|
<button
|
||||||
title={state.isDirty ? t('notes.saveNow') : t('notes.noModification')}
|
title={state.isDirty ? t('notes.saveNow') : t('notes.noModification')}
|
||||||
aria-label={state.isDirty ? t('notes.saveNoteAria') : t('notes.noChangesToSaveAria')}
|
aria-label={state.isDirty ? t('notes.saveNoteAria') : t('notes.noChangesToSaveAria')}
|
||||||
|
|||||||
Reference in New Issue
Block a user