Fix:Collection page set library on refresh

This commit is contained in:
advplyr 2022-11-27 14:22:46 -06:00
parent 084bea6b15
commit c1360267c6
2 changed files with 10 additions and 4 deletions

View File

@ -52,6 +52,11 @@ export default {
return redirect('/')
}
// If collection is a different library then set library as current
if (collection.libraryId !== store.state.libraries.currentLibraryId) {
await store.dispatch('libraries/fetch', collection.libraryId)
}
store.commit('libraries/addUpdateCollection', collection)
return {
collectionId: collection.id
@ -87,7 +92,7 @@ export default {
})
},
streaming() {
return !!this.playableBooks.find((b) => b.id === this.$store.getters['getLibraryItemIdStreaming'])
return !!this.playableBooks.some((b) => b.id === this.$store.getters['getLibraryItemIdStreaming'])
},
showPlayButton() {
return this.playableBooks.length
@ -109,14 +114,15 @@ export default {
this.$axios
.$delete(`/api/collections/${this.collection.id}`)
.then(() => {
this.processingRemove = false
this.$toast.success(this.$strings.ToastCollectionRemoveSuccess)
})
.catch((error) => {
console.error('Failed to remove collection', error)
this.processingRemove = false
this.$toast.error(this.$strings.ToastCollectionRemoveFailed)
})
.finally(() => {
this.processingRemove = false
})
}
},
clickPlay() {

View File

@ -7,7 +7,7 @@
<script>
export default {
async asyncData({ params, query, store, app, redirect }) {
async asyncData({ params, query, store, redirect }) {
var libraryId = params.library
var libraryData = await store.dispatch('libraries/fetch', libraryId)
if (!libraryData) {