From cda39e967ca1c4b1a7eadf3ef1fb45630b5b82ce Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 9 Dec 2025 16:02:24 +0200 Subject: [PATCH] chore(tab_navigation): address requested changes --- apps/client/src/widgets/react/hooks.tsx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index bd1085e4e..fbcd7095e 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -897,33 +897,31 @@ export function useChildNotes(parentNoteId: string | undefined) { } setChildNotes(childNotes ?? []); })(); - }, [ parentNoteId ]); + }, [ parentNoteId ]); return childNotes; } export function useLauncherVisibility(launchNoteId: string) { - const note = froca.getNoteFromCache(launchNoteId); - const [ isVisible, setIsVisible ] = useState(checkIfVisible(note)); + const checkIfVisible = useCallback(() => { + const note = froca.getNoteFromCache(launchNoteId); + return note?.getParentBranches().some(branch => + [ "_lbVisibleLaunchers", "_lbMobileVisibleLaunchers" ].includes(branch.parentNoteId)) ?? false; + }, [ launchNoteId ]); + + const [ isVisible, setIsVisible ] = useState(checkIfVisible()); // React to note not being available in the cache. useEffect(() => { - if (!note) return; - froca.getNote(launchNoteId).then(fetchedNote => setIsVisible(checkIfVisible(fetchedNote))); - }, [ note, launchNoteId ]); + froca.getNote(launchNoteId).then(() => setIsVisible(checkIfVisible())); + }, [ launchNoteId, checkIfVisible ]); // React to changes. useTriliumEvent("entitiesReloaded", ({ loadResults }) => { - if (!note) return; if (loadResults.getBranchRows().some(branch => branch.noteId === launchNoteId)) { - setIsVisible(checkIfVisible(note)); + setIsVisible(checkIfVisible()); } }); - function checkIfVisible(note: FNote | undefined | null) { - return note?.getParentBranches().some(branch => - [ "_lbVisibleLaunchers", "_lbMobileVisibleLaunchers" ].includes(branch.parentNoteId)) ?? false; - } - return isVisible; }