Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On item pages, fetch the item's library data to the store if it's not available #3212

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/pages/author/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions client/pages/item/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export default {
console.error('No item...', params.id)
return redirect('/')
}
if (store.state.libraries.currentLibraryId !== item.libraryId || !store.state.libraries.filterData) {
await store.dispatch('libraries/fetch', item.libraryId)
}
return {
libraryItem: item,
rssFeed: item.rssFeed || null,
Expand Down Expand Up @@ -791,10 +794,6 @@ export default {
this.episodeDownloadsQueued = this.libraryItem.episodeDownloadsQueued || []
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.$root.socket.on('item_updated', this.libraryItemUpdated)
this.$root.socket.on('rss_feed_open', this.rssFeedOpen)
Expand Down
20 changes: 12 additions & 8 deletions client/pages/library/_library/podcast/download-queue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -124,10 +132,6 @@ export default {
}
},
mounted() {
if (this.libraryId) {
this.$store.commit('libraries/setCurrentLibrary', this.libraryId)
}

this.loadInitialDownloadQueue()
},
beforeDestroy() {
Expand Down
16 changes: 0 additions & 16 deletions client/store/libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,6 @@ export const actions = {
commit('set', [])
})
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)
})
}
}

Expand Down
Loading