Skip to content

Build your personal knowledge base with Trilium Notes

fix(react): note context not always updated

Elian Doran799e705ff8b8
diff --git a/apps/client/src/widgets/basic_widget.ts b/apps/client/src/widgets/basic_widget.ts
index 22d1864fb1..3eb2e86f5e 100644
--- a/apps/client/src/widgets/basic_widget.ts
+++ b/apps/client/src/widgets/basic_widget.ts
@@ -293,7 +293,6 @@ export class ReactWrappedWidget extends BasicWidget {
handleEvent<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null | undefined {
const listener = this.listeners[name];
- console.log("Handle ", name, listener);
listener?.(data);
}
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 925ac24f12..d43d25f610 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -231,19 +231,19 @@ export function useNoteContext() {
const [ noteContext, setNoteContext ] = useState<NoteContext>();
const [ notePath, setNotePath ] = useState<string | null | undefined>();
- useTriliumEvent("activeContextChanged", ({ noteContext }) => {
- console.log("Active context changed.");
+ useTriliumEventBeta("activeContextChanged", ({ noteContext }) => {
setNoteContext(noteContext);
+ setNotePath(noteContext.notePath);
});
useTriliumEventBeta("setNoteContext", ({ noteContext }) => {
console.log("Set note context", noteContext, noteContext.noteId);
setNoteContext(noteContext);
});
- useTriliumEvent("noteSwitchedAndActivated", ({ noteContext }) => {
+ useTriliumEventBeta("noteSwitchedAndActivated", ({ noteContext }) => {
console.log("Note switched and activated")
setNoteContext(noteContext);
});
- useTriliumEvent("noteSwitched", ({ noteContext, notePath }) => {
+ useTriliumEventBeta("noteSwitched", ({ noteContext, notePath }) => {
console.warn("Note switched", notePath);
setNotePath(notePath);
});