chore(react/launch_bar): port open_note_button_widget

This commit is contained in:
Elian Doran
2025-12-04 14:18:04 +02:00
parent 1af6200655
commit 48cbb80e79
6 changed files with 87 additions and 63 deletions

View File

@@ -23,6 +23,7 @@ import toast, { ToastOptions } from "../../services/toast";
import utils, { escapeRegExp, reloadFrontendApp } from "../../services/utils";
import server from "../../services/server";
import { removeIndividualBinding } from "../../services/shortcuts";
import froca from "../../services/froca";
export function useTriliumEvent<T extends EventNames>(eventName: T, handler: (data: EventData<T>) => void) {
const parentComponent = useContext(ParentComponent);
@@ -836,3 +837,15 @@ async function isNoteReadOnly(note: FNote, noteContext: NoteContext) {
return true;
}
export function useChildNotes(parentNoteId: string) {
const [ childNotes, setChildNotes ] = useState<FNote[]>([]);
async function refreshChildNotes() {
const parentNote = await froca.getNote(parentNoteId);
const childNotes = await parentNote?.getChildNotes();
setChildNotes(childNotes ?? []);
}
useEffect(() => { refreshChildNotes() }, [ parentNoteId ]);
return childNotes;
}