From ddcda197b4a709680089e030ab5ca0b489762786 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 30 Mar 2025 17:27:36 -0500 Subject: [PATCH] Fix manage, chapters edit tracks and library stats page not setting the current library properly #4170 --- client/pages/audiobook/_id/chapters.vue | 5 +++++ client/pages/audiobook/_id/edit.vue | 6 ++++++ client/pages/audiobook/_id/manage.vue | 7 ++++++- client/pages/library/_library/stats.vue | 8 +++++--- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 71abef33..7b56f5c9 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -221,6 +221,11 @@ export default { return redirect('/') } + // Fetch and set library if this items library does not match the current + if (store.state.libraries.currentLibraryId !== libraryItem.libraryId || !store.state.libraries.filterData) { + await store.dispatch('libraries/fetch', libraryItem.libraryId) + } + var previousRoute = from ? from.fullPath : null if (from && from.path === '/login') previousRoute = null return { diff --git a/client/pages/audiobook/_id/edit.vue b/client/pages/audiobook/_id/edit.vue index e29ab9e3..3aad3f80 100644 --- a/client/pages/audiobook/_id/edit.vue +++ b/client/pages/audiobook/_id/edit.vue @@ -103,6 +103,12 @@ export default { console.error('No need to edit library item that is 1 file...') return redirect('/') } + + // Fetch and set library if this items library does not match the current + if (store.state.libraries.currentLibraryId !== libraryItem.libraryId || !store.state.libraries.filterData) { + await store.dispatch('libraries/fetch', libraryItem.libraryId) + } + return { libraryItem, files: libraryItem.media.audioFiles ? libraryItem.media.audioFiles.map((af) => ({ ...af, include: !af.exclude })) : [] diff --git a/client/pages/audiobook/_id/manage.vue b/client/pages/audiobook/_id/manage.vue index 30e615bb..3d9ac051 100644 --- a/client/pages/audiobook/_id/manage.vue +++ b/client/pages/audiobook/_id/manage.vue @@ -195,10 +195,15 @@ export default { return redirect('/?error=invalid media type') } if (!libraryItem.media.audioFiles.length) { - cnosole.error('No audio files') + console.error('No audio files') return redirect('/?error=no audio files') } + // Fetch and set library if this items library does not match the current + if (store.state.libraries.currentLibraryId !== libraryItem.libraryId || !store.state.libraries.filterData) { + await store.dispatch('libraries/fetch', libraryItem.libraryId) + } + return { libraryItem } diff --git a/client/pages/library/_library/stats.vue b/client/pages/library/_library/stats.vue index 575c4676..0fcc2a41 100644 --- a/client/pages/library/_library/stats.vue +++ b/client/pages/library/_library/stats.vue @@ -89,14 +89,16 @@