From 7cc7e32c33f30f6629176b3b94595bf12af7ad7a Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 20 Nov 2023 12:18:37 -0800 Subject: [PATCH] Prune deleted folders off of breadcrumbs' longest visited (keeps current folder even if missing). --- frontend/src/components/BreadCrumb.vue | 10 ++++++++++ frontend/src/components/EmptyFolder.vue | 3 ++- frontend/src/utils/fileutil.ts | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 frontend/src/utils/fileutil.ts diff --git a/frontend/src/components/BreadCrumb.vue b/frontend/src/components/BreadCrumb.vue index ad6288e..c35f669 100644 --- a/frontend/src/components/BreadCrumb.vue +++ b/frontend/src/components/BreadCrumb.vue @@ -34,6 +34,7 @@ import home from '@/assets/svg/home.svg' import { nextTick, onBeforeUpdate, ref, watchEffect } from 'vue' import { useRouter } from 'vue-router' +import { exists } from '@/utils/fileutil' const router = useRouter() @@ -86,6 +87,15 @@ watchEffect(() => { else if (props.path.length > longcut.length) { longest.value = longcut.concat(props.path.slice(longcut.length)) } + else { + // Prune deleted folders from longest + for (let i = props.path.length; i < longest.value.length; ++i) { + if (!exists(longest.value.slice(0, i + 1))) { + longest.value = longest.value.slice(0, i) + break + } + } + } // If needed, focus primary navigation to new location if (props.primary) nextTick(() => { const act = document.activeElement as HTMLElement diff --git a/frontend/src/components/EmptyFolder.vue b/frontend/src/components/EmptyFolder.vue index 4313f8a..8134a56 100644 --- a/frontend/src/components/EmptyFolder.vue +++ b/frontend/src/components/EmptyFolder.vue @@ -4,7 +4,7 @@

No Connection

Waiting for File List

No matches!

-

Folder not found

+

Folder not found

Empty folder

@@ -13,6 +13,7 @@ import { defineProps } from 'vue' import { useMainStore } from '@/stores/main' import cog from '@/assets/svg/cog.svg' +import { exists } from '@/utils/fileutil' const store = useMainStore() const props = defineProps<{ diff --git a/frontend/src/utils/fileutil.ts b/frontend/src/utils/fileutil.ts new file mode 100644 index 0000000..183f5aa --- /dev/null +++ b/frontend/src/utils/fileutil.ts @@ -0,0 +1,5 @@ +import { useMainStore } from '@/stores/main' + +const store = useMainStore() + +export const exists = (path: string[]) => store.document.some(doc => (doc.loc ? `${doc.loc}/${doc.name}` : doc.name) === path.join('/'))