Revert "chore(react): prototype for note context"

This reverts commit 660db3b3ab.
This commit is contained in:
Elian Doran
2025-08-25 13:51:43 +03:00
parent 660db3b3ab
commit 1eaeec8100
6 changed files with 19 additions and 61 deletions

View File

@@ -17,13 +17,9 @@ import { CSSProperties } from "preact/compat";
export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {
const parentComponent = useContext(ParentComponent)!;
useEffect(() => {
parentComponent.registerHandler(eventName, handler);
return (() => parentComponent.removeHandler(eventName, handler));
}, [eventName, handler]);
parentComponent.registerHandler(eventName, handler);
useDebugValue(eventName);
return (() => parentComponent.removeHandler(eventName, handler));
}
export function useTriliumEvents<T extends EventNames>(eventNames: T[], handler: (data: EventData<T>, eventName: T) => void) {
@@ -203,6 +199,7 @@ export function useNoteContext() {
}, [ notePath ]);
useTriliumEvent("activeContextChanged", ({ noteContext }) => {
setNoteContext(noteContext);
setNotePath(noteContext.notePath);
});
useTriliumEvent("setNoteContext", ({ noteContext }) => {