mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-10 03:53:37 -06:00
chore(tab_navigation): address requested changes
This commit is contained in:
parent
7da9367dc9
commit
cda39e967c
@ -903,27 +903,25 @@ export function useChildNotes(parentNoteId: string | undefined) {
|
||||
}
|
||||
|
||||
export function useLauncherVisibility(launchNoteId: string) {
|
||||
const checkIfVisible = useCallback(() => {
|
||||
const note = froca.getNoteFromCache(launchNoteId);
|
||||
const [ isVisible, setIsVisible ] = useState<boolean>(checkIfVisible(note));
|
||||
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.
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user