Skip to content

Build your personal knowledge base with Trilium Notes

fix(react/type_widgets): unable to switch view-mode for same note

Elian Doran5c21759de99a
diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx
index d4fd9d22ad..dc3e8dd130 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]);
+ useEffect(refresh, [ actualNote, noteContext, noteContext?.viewScope?.viewMode ]);
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 8b6df6d072..191ba497d4 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -239,6 +239,7 @@ export function useNoteContext() {
const [ noteContext, setNoteContext ] = useState<NoteContext>();
const [ notePath, setNotePath ] = useState<string | null | undefined>();
const [ note, setNote ] = useState<FNote | null | undefined>();
+ const [ , setViewMode ] = useState<string>();
const [ refreshCounter, setRefreshCounter ] = useState(0);
useEffect(() => {
@@ -248,6 +249,7 @@ export function useNoteContext() {
useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => {
setNoteContext(noteContext);
setNotePath(noteContext.notePath);
+ setViewMode(noteContext.viewScope?.viewMode);
});
useTriliumEvent("frocaReloaded", () => {
setNote(noteContext?.note);