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

This commit is contained in:
Elian Doran 2025-08-27 13:06:57 +03:00
parent 066f3ea078
commit 82bdb76d75
No known key found for this signature in database

View file

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