refactor: migrate remaining components to useRefresh hook

Replace triggerRefresh() with useRefresh() in:
- notes-tabs-view.tsx (5 calls → refreshNotes)
- label-management-dialog.tsx (3 calls → refreshLabels)
- note-inline-editor.tsx (3 calls → refreshNotes)
- note-card.tsx (7 calls → refreshNotes)
- recent-notes-section.tsx (3 calls → refreshNotes)
- notification-panel.tsx (2 calls → refreshNotes(null))
- notes-editorial-view.tsx (4 calls → refreshNotes)

NoteRefreshContext marked as @deprecated with JSDoc migration guide.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Antigravity
2026-05-08 14:45:50 +00:00
parent 9b8df398dc
commit 574c8b3166
8 changed files with 151 additions and 59 deletions

View File

@@ -59,7 +59,7 @@ const ComparisonModal = dynamic(() => import('./comparison-modal').then(m => ({
const FusionModal = dynamic(() => import('./fusion-modal').then(m => ({ default: m.FusionModal })), { ssr: false })
import { useConnectionsCompare } from '@/hooks/use-connections-compare'
import { useNotebooks } from '@/context/notebooks-context'
import { useNoteRefresh } from '@/context/NoteRefreshContext'
import { useRefresh } from '@/lib/use-refresh'
import { useLanguage } from '@/lib/i18n'
import { toast } from 'sonner'
@@ -171,7 +171,7 @@ export const NoteCard = memo(function NoteCard({
}: NoteCardProps) {
const router = useRouter()
const searchParams = useSearchParams()
const { triggerRefresh } = useNoteRefresh()
const { refreshNotes } = useRefresh()
const { data: session } = useSession()
const { t, language } = useLanguage()
const { notebooks, moveNoteToNotebookOptimistic, refreshLabels } = useNotebooks()
@@ -201,7 +201,7 @@ export const NoteCard = memo(function NoteCard({
try {
await updateNote(noteId, { reminder })
setReminderDate(reminder)
triggerRefresh()
refreshNotes(note?.notebookId)
if (reminder) {
toast.success(t('notes.reminderSet', { datetime: reminder.toLocaleString() }))
} else {
@@ -217,7 +217,7 @@ export const NoteCard = memo(function NoteCard({
const handleMoveToNotebook = async (notebookId: string | null) => {
await moveNoteToNotebookOptimistic(note.id, notebookId)
setShowNotebookMenu(false)
// No need for router.refresh() - triggerRefresh() is already called in moveNoteToNotebookOptimistic
// No need for router.refresh() - refreshNotes(note?.notebookId) is already called in moveNoteToNotebookOptimistic
}
// Optimistic UI state for instant feedback
@@ -302,7 +302,7 @@ export const NoteCard = memo(function NoteCard({
try {
await deleteNote(note.id)
await refreshLabels()
triggerRefresh() // met à jour la liste et le compteur du carnet
refreshNotes(note?.notebookId) // met à jour la liste et le compteur du carnet
} catch (error) {
console.error('Failed to delete note:', error)
setIsHidden(false)
@@ -315,7 +315,7 @@ export const NoteCard = memo(function NoteCard({
setIsHidden(true)
try {
await restoreNote(note.id)
triggerRefresh()
refreshNotes(note?.notebookId)
toast.success(t('trash.noteRestored'))
} catch (error) {
console.error('Failed to restore note:', error)
@@ -329,7 +329,7 @@ export const NoteCard = memo(function NoteCard({
setIsHidden(true)
try {
await permanentDeleteNote(note.id)
triggerRefresh()
refreshNotes(note?.notebookId)
toast.success(t('trash.notePermanentlyDeleted'))
} catch (error) {
console.error('Failed to permanently delete note:', error)
@@ -342,7 +342,7 @@ export const NoteCard = memo(function NoteCard({
startTransition(async () => {
addOptimisticNote({ isPinned: !note.isPinned })
await togglePin(note.id, !note.isPinned)
triggerRefresh()
refreshNotes(note?.notebookId)
if (!note.isPinned) {
toast.success(t('notes.pinned') || 'Note pinned')
@@ -356,7 +356,7 @@ export const NoteCard = memo(function NoteCard({
startTransition(async () => {
addOptimisticNote({ isArchived: !note.isArchived })
await toggleArchive(note.id, !note.isArchived)
triggerRefresh()
refreshNotes(note?.notebookId)
})
}
@@ -809,7 +809,7 @@ export const NoteCard = memo(function NoteCard({
}
toast.success(t('toast.notesFusionSuccess'))
setFusionNotes([])
triggerRefresh()
refreshNotes(note?.notebookId)
}}
/>
</div>