Skip to content

Build your personal knowledge base with Trilium Notes

fix(react/floating_buttons): react to note type/mime changes

Elian Doran03a7fe1282d9
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index d1719b1478..af53781446 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -196,6 +196,7 @@ export function useNoteContext() {
const [ noteContext, setNoteContext ] = useState<NoteContext>();
const [ notePath, setNotePath ] = useState<string | null | undefined>();
const [ note, setNote ] = useState<FNote | null | undefined>();
+ const [ refreshCounter, setRefreshCounter ] = useState(0);
useEffect(() => {
setNote(noteContext?.note);
@@ -208,6 +209,11 @@ export function useNoteContext() {
useTriliumEvent("frocaReloaded", () => {
setNote(noteContext?.note);
});
+ useTriliumEvent("noteTypeMimeChanged", ({ noteId }) => {
+ if (noteId === note?.noteId) {
+ setRefreshCounter(refreshCounter + 1);
+ }
+ });
const parentComponent = useContext(ParentComponent) as ReactWrappedWidget;
useDebugValue(() => `notePath=${notePath}, ntxId=${noteContext?.ntxId}`);