mirror of
https://github.com/zadam/trilium.git
synced 2025-12-29 10:44:25 +01:00
fix(launch_bar): bookmarks not refreshing
Some checks failed
Checks / main (push) Has been cancelled
Some checks failed
Checks / main (push) Has been cancelled
This commit is contained in:
parent
4a2ff25052
commit
52aaa72935
@ -1011,17 +1011,27 @@ async function isNoteReadOnly(note: FNote, noteContext: NoteContext) {
|
||||
|
||||
export function useChildNotes(parentNoteId: string | undefined) {
|
||||
const [ childNotes, setChildNotes ] = useState<FNote[]>([]);
|
||||
useEffect(() => {
|
||||
(async function() {
|
||||
let childNotes: FNote[] | undefined;
|
||||
if (parentNoteId) {
|
||||
const parentNote = await froca.getNote(parentNoteId);
|
||||
childNotes = await parentNote?.getChildNotes();
|
||||
}
|
||||
setChildNotes(childNotes ?? []);
|
||||
})();
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
let childNotes: FNote[] | undefined;
|
||||
if (parentNoteId) {
|
||||
const parentNote = await froca.getNote(parentNoteId);
|
||||
childNotes = await parentNote?.getChildNotes();
|
||||
}
|
||||
setChildNotes(childNotes ?? []);
|
||||
}, [ parentNoteId ]);
|
||||
|
||||
useEffect(() => {
|
||||
refresh();
|
||||
}, [ refresh ]);
|
||||
|
||||
// Refresh on branch changes.
|
||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||
if (parentNoteId && loadResults.getBranchRows().some(branch => branch.parentNoteId === parentNoteId)) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
return childNotes;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user