Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(launch_bar): bookmarks not refreshing
Elian Doran52aaa729352a
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 9a688c10e1..e3e750c4a6 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -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;}