Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/ribbon): simplify useNoteContext & handle setNoteContext

Elian Doran82bdb76d75b0
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 1110f4e1b8..0b0cea3a0d 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -202,17 +202,10 @@ export function useNoteContext() {
setNote(noteContext?.note);
}, [ notePath ]);
- useTriliumEvent("activeContextChanged", ({ noteContext }) => {
+ useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => {
setNoteContext(noteContext);
setNotePath(noteContext.notePath);
});
- useTriliumEvent("noteSwitchedAndActivated", ({ noteContext }) => {
- setNoteContext(noteContext);
- });
- useTriliumEvent("noteSwitched", ({ notePath, noteContext }) => {
- setNoteContext(noteContext);
- setNotePath(notePath);
- });
useTriliumEvent("frocaReloaded", () => {
setNote(noteContext?.note);
});