mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-11 14:01:38 -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) {
|
export function useLauncherVisibility(launchNoteId: string) {
|
||||||
|
const checkIfVisible = useCallback(() => {
|
||||||
const note = froca.getNoteFromCache(launchNoteId);
|
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.
|
// 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;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user