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`)
}
if (query.library) {
store.commit('libraries/setCurrentLibrary', query.library)
if (store.state.libraries.currentLibraryId !== author.libraryId || !store.state.libraries.filterData) {
await store.dispatch('libraries/fetch', author.libraryId)
}
return {

View File

@ -54,11 +54,19 @@
<script>
export default {
async asyncData({ params, redirect }) {
if (!params.library) {
console.error('No library...', params.library)
return redirect('/')
async asyncData({ params, redirect, store }) {
var libraryId = params.library
var libraryData = await store.dispatch('libraries/fetch', libraryId)
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 {
libraryId: params.library
}
@ -124,10 +132,6 @@ export default {
}
},
mounted() {
if (this.libraryId) {
this.$store.commit('libraries/setCurrentLibrary', this.libraryId)
}
this.loadInitialDownloadQueue()
},
beforeDestroy() {