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:
@@ -10,7 +10,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
|
||||
import { togglePin, deleteNote, dismissFromRecent } from '@/app/actions/notes'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useNotebooks } from '@/context/notebooks-context'
|
||||
import { useNoteRefresh } from '@/context/NoteRefreshContext'
|
||||
import { useRefresh } from '@/lib/use-refresh'
|
||||
import { toast } from 'sonner'
|
||||
import { StickyNote } from 'lucide-react'
|
||||
|
||||
@@ -64,7 +64,7 @@ function CompactCard({
|
||||
const { t } = useLanguage()
|
||||
const router = useRouter()
|
||||
const { notebooks, moveNoteToNotebookOptimistic } = useNotebooks()
|
||||
const { triggerRefresh } = useNoteRefresh()
|
||||
const { refreshNotes } = useRefresh()
|
||||
const [isDeleting, setIsDeleting] = useState(false)
|
||||
const [showNotebookMenu, setShowNotebookMenu] = useState(false)
|
||||
const [, startTransition] = useTransition()
|
||||
@@ -86,7 +86,7 @@ function CompactCard({
|
||||
await togglePin(note.id, newPinnedState)
|
||||
|
||||
// Trigger global refresh to update lists
|
||||
triggerRefresh()
|
||||
refreshNotes(note?.notebookId)
|
||||
router.refresh()
|
||||
|
||||
if (newPinnedState) {
|
||||
@@ -100,7 +100,7 @@ function CompactCard({
|
||||
const handleMoveToNotebook = async (notebookId: string | null) => {
|
||||
await moveNoteToNotebookOptimistic(note.id, notebookId)
|
||||
setShowNotebookMenu(false)
|
||||
triggerRefresh()
|
||||
refreshNotes(note?.notebookId)
|
||||
}
|
||||
|
||||
const handleDelete = async (e: React.MouseEvent) => {
|
||||
@@ -112,7 +112,7 @@ function CompactCard({
|
||||
setIsDeleting(true)
|
||||
try {
|
||||
await deleteNote(note.id)
|
||||
triggerRefresh()
|
||||
refreshNotes(note?.notebookId)
|
||||
router.refresh()
|
||||
} catch (error) {
|
||||
console.error('Failed to delete note:', error)
|
||||
@@ -135,7 +135,7 @@ function CompactCard({
|
||||
try {
|
||||
await dismissFromRecent(note.id)
|
||||
// Don't refresh list to prevent immediate replacement
|
||||
// triggerRefresh()
|
||||
// refreshNotes(note?.notebookId)
|
||||
// router.refresh()
|
||||
toast.success(t('notes.dismissed') || 'Note dismissed from recent')
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user