mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-25 20:22:32 +02:00
Merge pull request #3212 from mikiher/library-fetch
On item pages, fetch the item's library data to the store if it's not available
This commit is contained in:
commit
787c4e45a8
@ -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 {
|
||||||
|
@ -168,6 +168,9 @@ export default {
|
|||||||
console.error('No item...', params.id)
|
console.error('No item...', params.id)
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
}
|
}
|
||||||
|
if (store.state.libraries.currentLibraryId !== item.libraryId || !store.state.libraries.filterData) {
|
||||||
|
await store.dispatch('libraries/fetch', item.libraryId)
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
libraryItem: item,
|
libraryItem: item,
|
||||||
rssFeed: item.rssFeed || null,
|
rssFeed: item.rssFeed || null,
|
||||||
@ -791,10 +794,6 @@ export default {
|
|||||||
this.episodeDownloadsQueued = this.libraryItem.episodeDownloadsQueued || []
|
this.episodeDownloadsQueued = this.libraryItem.episodeDownloadsQueued || []
|
||||||
this.episodesDownloading = this.libraryItem.episodesDownloading || []
|
this.episodesDownloading = this.libraryItem.episodesDownloading || []
|
||||||
|
|
||||||
// use this items library id as the current
|
|
||||||
if (this.libraryId) {
|
|
||||||
this.$store.commit('libraries/setCurrentLibrary', this.libraryId)
|
|
||||||
}
|
|
||||||
this.$eventBus.$on(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
|
this.$eventBus.$on(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
|
||||||
this.$root.socket.on('item_updated', this.libraryItemUpdated)
|
this.$root.socket.on('item_updated', this.libraryItemUpdated)
|
||||||
this.$root.socket.on('rss_feed_open', this.rssFeedOpen)
|
this.$root.socket.on('rss_feed_open', this.rssFeedOpen)
|
||||||
|
@ -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() {
|
||||||
|
@ -166,22 +166,6 @@ export const actions = {
|
|||||||
commit('set', [])
|
commit('set', [])
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
},
|
|
||||||
loadLibraryFilterData({ state, commit, rootState }) {
|
|
||||||
if (!rootState.user || !rootState.user.user) {
|
|
||||||
console.error('libraries/loadLibraryFilterData - User not set')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$axios
|
|
||||||
.$get(`/api/libraries/${state.currentLibraryId}/filterdata`)
|
|
||||||
.then((data) => {
|
|
||||||
commit('setLibraryFilterData', data)
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Failed', error)
|
|
||||||
commit('setLibraryFilterData', null)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user