fix(react): note context not always updated

This commit is contained in:
Elian Doran 2025-08-21 09:17:47 +03:00
parent 59486cd55d
commit 799e705ff8
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View File

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

View File

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