Replace setCurrentLibrary calls with fetch to ensure filterData matches library

This commit is contained in:
advplyr 2024-07-30 16:35:26 -05:00
parent 03818fadee
commit 006241163b
2 changed files with 14 additions and 10 deletions

View File

@ -56,8 +56,8 @@ export default {
return redirect(`/library/${store.state.libraries.currentLibraryId}/authors`) return redirect(`/library/${store.state.libraries.currentLibraryId}/authors`)
} }
if (query.library) { if (store.state.libraries.currentLibraryId !== author.libraryId || !store.state.libraries.filterData) {
store.commit('libraries/setCurrentLibrary', query.library) await store.dispatch('libraries/fetch', author.libraryId)
} }
return { return {

View File

@ -54,11 +54,19 @@
<script> <script>
export default { export default {
async asyncData({ params, redirect }) { async asyncData({ params, redirect, store }) {
if (!params.library) { var libraryId = params.library
console.error('No library...', params.library) var libraryData = await store.dispatch('libraries/fetch', libraryId)
return redirect('/') if (!libraryData) {
return redirect('/oops?message=Library not found')
} }
// Redirect book libraries
const library = libraryData.library
if (library.mediaType === 'book') {
return redirect(`/library/${libraryId}`)
}
return { return {
libraryId: params.library libraryId: params.library
} }
@ -124,10 +132,6 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.libraryId) {
this.$store.commit('libraries/setCurrentLibrary', this.libraryId)
}
this.loadInitialDownloadQueue() this.loadInitialDownloadQueue()
}, },
beforeDestroy() { beforeDestroy() {