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

This commit is contained in:
Elian Doran 2025-09-25 18:39:47 +03:00
parent e2ef58ed50
commit 5c21759de9
No known key found for this signature in database
2 changed files with 3 additions and 1 deletions

View File

@ -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();

View File

@ -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);