A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
chore: code style
aminnausin4f519d4d2775
diff --git a/resources/js/components/dashboard/DashboardLibraries.vue b/resources/js/components/dashboard/DashboardLibraries.vueindex d0853abd..06ef64d9 100644--- a/resources/js/components/dashboard/DashboardLibraries.vue+++ b/resources/js/components/dashboard/DashboardLibraries.vue@@ -3,7 +3,7 @@ import type { CategoryResource, FolderResource } from '@/types/resources';import type { BreadCrumbItem } from '@/types/types';import { folderSortingOptions, librarySortingOptions } from '@/constants/sortingOptions';-import { computed, ref, watchEffect } from 'vue';+import { computed, ref, watch } from 'vue';import { startScanFilesTask } from '@/service/siteAPI';import { useDashboardStore } from '@/stores/DashboardStore';import { useModalStore } from '@/stores/ModalStore';@@ -30,12 +30,13 @@ const { stateLibraries, isLoadingLibraries, stateLibraryId, stateLibraryFolders,const { pageTitle } = storeToRefs(useAppStore());const confirmModal = useModal({ title: 'Delete Library?', submitText: 'Confim' });-const cachedLibrary = ref<CategoryResource>();const searchQuery = ref('');const cachedID = ref<null | number>(null);const modal = useModalStore();+const currentLibrary = computed<CategoryResource | undefined>(() => stateLibraries.value.find((lib) => lib.id == stateLibraryId.value));+const breadCrumbs = computed(() => {const items: BreadCrumbItem[] = [{@@ -50,12 +51,12 @@ const breadCrumbs = computed(() => {},];- if (cachedLibrary.value)+ if (currentLibrary.value)return [...items,{- name: cachedLibrary.value.name,- url: `/dashboard/libraries/${cachedLibrary.value.id}`,+ name: currentLibrary.value.name,+ url: `/dashboard/libraries/${currentLibrary.value.id}`,},];return items;@@ -129,7 +130,7 @@ const handleScanLibrary = async (id?: number) => {try {await startScanFilesTask(stateLibraryId.value);- const scanMessage = 'Submitted scan request' + (cachedLibrary.value?.name ? ` for ${cachedLibrary.value.name}!` : '!');+ const scanMessage = 'Submitted scan request' + (currentLibrary.value?.name ? ` for ${currentLibrary.value.name}!` : '!');toast.add('Success', { type: 'success', description: scanMessage });} catch (error) {@@ -144,14 +145,16 @@ const handleFolderAction = (_: any, id: number, action: 'edit' | 'share' = 'editif (action === 'edit') modal.open(EditFolderModal, { cachedFolder: folder, queryKeys: [['libraryFolders']] });};-watchEffect(() => {- cachedLibrary.value = stateLibraries.value.find((library: CategoryResource) => library.id == stateLibraryId.value);-- const title = cachedLibrary.value ? `Content Libraries · ${cachedLibrary.value.name}` : 'Content Libraries';- pageTitle.value = title;- document.title = title;- searchQuery.value = '';-});+watch(+ currentLibrary,+ (library) => {+ const title = `Content Libraries${library ? ` · ${library.name}` : ''}`;+ pageTitle.value = title;+ document.title = title;+ searchQuery.value = '';+ },+ { immediate: true },+);</script><template><div class="flex flex-wrap items-center justify-between gap-2">