From 5bfa0d13e3fc84c73ff6a56e83d888d2020ad3c9 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 25 Sep 2025 18:44:06 +0300 Subject: [PATCH] chore(react/type_widgets): refresh on all viewscope changes --- apps/client/src/widgets/NoteDetail.tsx | 2 +- apps/client/src/widgets/react/hooks.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx index dc3e8dd13..9378be28e 100644 --- a/apps/client/src/widgets/NoteDetail.tsx +++ b/apps/client/src/widgets/NoteDetail.tsx @@ -136,7 +136,7 @@ function useNoteInfo() { }); } - useEffect(refresh, [ actualNote, noteContext, noteContext?.viewScope?.viewMode ]); + useEffect(refresh, [ actualNote, noteContext, noteContext?.viewScope ]); useTriliumEvent("readOnlyTemporarilyDisabled", ({ noteContext: eventNoteContext }) => { if (eventNoteContext?.ntxId !== noteContext?.ntxId) return; refresh(); diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 191ba497d..24400a584 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -22,6 +22,7 @@ import toast, { ToastOptions } from "../../services/toast"; import protected_session_holder from "../../services/protected_session_holder"; import server from "../../services/server"; import { removeIndividualBinding } from "../../services/shortcuts"; +import { ViewScope } from "../../services/link"; export function useTriliumEvent(eventName: T, handler: (data: EventData) => void) { const parentComponent = useContext(ParentComponent); @@ -239,7 +240,7 @@ export function useNoteContext() { const [ noteContext, setNoteContext ] = useState(); const [ notePath, setNotePath ] = useState(); const [ note, setNote ] = useState(); - const [ , setViewMode ] = useState(); + const [ , setViewScope ] = useState(); const [ refreshCounter, setRefreshCounter ] = useState(0); useEffect(() => { @@ -249,7 +250,7 @@ export function useNoteContext() { useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => { setNoteContext(noteContext); setNotePath(noteContext.notePath); - setViewMode(noteContext.viewScope?.viewMode); + setViewScope(noteContext.viewScope); }); useTriliumEvent("frocaReloaded", () => { setNote(noteContext?.note);