chore(tab_navigation): address requested changes

This commit is contained in:
Elian Doran 2025-12-09 16:02:24 +02:00
parent 7da9367dc9
commit cda39e967c
No known key found for this signature in database

View File

@ -897,33 +897,31 @@ export function useChildNotes(parentNoteId: string | undefined) {
} }
setChildNotes(childNotes ?? []); setChildNotes(childNotes ?? []);
})(); })();
}, [ parentNoteId ]); }, [ parentNoteId ]);
return childNotes; return childNotes;
} }
export function useLauncherVisibility(launchNoteId: string) { export function useLauncherVisibility(launchNoteId: string) {
const note = froca.getNoteFromCache(launchNoteId); const checkIfVisible = useCallback(() => {
const [ isVisible, setIsVisible ] = useState<boolean>(checkIfVisible(note)); const note = froca.getNoteFromCache(launchNoteId);
return note?.getParentBranches().some(branch =>
[ "_lbVisibleLaunchers", "_lbMobileVisibleLaunchers" ].includes(branch.parentNoteId)) ?? false;
}, [ launchNoteId ]);
const [ isVisible, setIsVisible ] = useState<boolean>(checkIfVisible());
// React to note not being available in the cache. // React to note not being available in the cache.
useEffect(() => { useEffect(() => {
if (!note) return; froca.getNote(launchNoteId).then(() => setIsVisible(checkIfVisible()));
froca.getNote(launchNoteId).then(fetchedNote => setIsVisible(checkIfVisible(fetchedNote))); }, [ launchNoteId, checkIfVisible ]);
}, [ note, launchNoteId ]);
// React to changes. // React to changes.
useTriliumEvent("entitiesReloaded", ({ loadResults }) => { useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
if (!note) return;
if (loadResults.getBranchRows().some(branch => branch.noteId === launchNoteId)) { 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; return isVisible;
} }