refactor: home-client uses useRefresh() for note invalidation
Replace direct triggerRefresh() with useRefresh().refreshNotes() in handleEditorClose. This invalidates the notes cache via React Query and triggers the old refresh mechanism for backward compat. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { NotebookSuggestionToast } from '@/components/notebook-suggestion-toast'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Plus, ArrowUpDown } from 'lucide-react'
|
||||
import { useNoteRefresh } from '@/context/NoteRefreshContext'
|
||||
import { useRefresh } from '@/lib/use-refresh'
|
||||
import { useReminderCheck } from '@/hooks/use-reminder-check'
|
||||
import { useAutoLabelSuggestion } from '@/hooks/use-auto-label-suggestion'
|
||||
import { useNotebooks } from '@/context/notebooks-context'
|
||||
@@ -73,6 +74,7 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) {
|
||||
const notesRef = useRef(notes)
|
||||
notesRef.current = notes
|
||||
const { refreshKey, triggerRefresh } = useNoteRefresh()
|
||||
const { refreshNotes } = useRefresh()
|
||||
const { labels, notebooks } = useNotebooks()
|
||||
const { setControls } = useEditorUI()
|
||||
|
||||
@@ -341,8 +343,9 @@ export function HomeClient({ initialNotes, initialSettings }: HomeClientProps) {
|
||||
params.delete('openNote')
|
||||
const qs = params.toString()
|
||||
router.replace(qs ? `/?${qs}` : '/', { scroll: false })
|
||||
triggerRefresh()
|
||||
}, [triggerRefresh, router, searchParams])
|
||||
// Invalidate notes cache and trigger refresh
|
||||
refreshNotes(searchParams.get('notebook') || null)
|
||||
}, [refreshNotes, router, searchParams])
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user