mirror of
https://github.com/sudoxnym/audiobookshelf-atv.git
synced 2026-05-22 13:48:23 +00:00
Fix:Podcast latest and book authors page refresh/redirect on library change
This commit is contained in:
parent
1ea984b915
commit
7818500f0f
2 changed files with 30 additions and 2 deletions
|
|
@ -15,7 +15,8 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
authors: []
|
||||
authors: [],
|
||||
loadedLibraryId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -25,6 +26,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async init() {
|
||||
this.loadedLibraryId = this.currentLibraryId
|
||||
this.authors = await this.$axios
|
||||
.$get(`/api/libraries/${this.currentLibraryId}/authors`)
|
||||
.then((response) => response.authors)
|
||||
|
|
@ -53,6 +55,15 @@ export default {
|
|||
authorRemoved(author) {
|
||||
this.authors = this.authors.filter((au) => au.id !== author.id)
|
||||
this.$eventBus.$emit('bookshelf-total-entities', this.authors.length)
|
||||
},
|
||||
libraryChanged(libraryId) {
|
||||
if (libraryId !== this.loadedLibraryId) {
|
||||
if (this.$store.getters['libraries/getCurrentLibraryMediaType'] === 'book') {
|
||||
this.init()
|
||||
} else {
|
||||
this.$router.replace('/bookshelf')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
@ -60,11 +71,13 @@ export default {
|
|||
this.$socket.$on('author_added', this.authorAdded)
|
||||
this.$socket.$on('author_updated', this.authorUpdated)
|
||||
this.$socket.$on('author_removed', this.authorRemoved)
|
||||
this.$eventBus.$on('library-changed', this.libraryChanged)
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$socket.$off('author_added', this.authorAdded)
|
||||
this.$socket.$off('author_updated', this.authorUpdated)
|
||||
this.$socket.$off('author_removed', this.authorRemoved)
|
||||
this.$eventBus.$off('library-changed', this.libraryChanged)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -17,7 +17,8 @@ export default {
|
|||
totalEpisodes: 0,
|
||||
currentPage: 0,
|
||||
localEpisodeMap: {},
|
||||
isLocal: false
|
||||
isLocal: false,
|
||||
loadedLibraryId: null
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
|
|
@ -39,6 +40,7 @@ export default {
|
|||
this.$store.commit('globals/setShowPlaylistsAddCreateModal', true)
|
||||
},
|
||||
async loadRecentEpisodes(page = 0) {
|
||||
this.loadedLibraryId = this.currentLibraryId
|
||||
this.processing = true
|
||||
const episodePayload = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/recent-episodes?limit=25&page=${page}`).catch((error) => {
|
||||
console.error('Failed to get recent episodes', error)
|
||||
|
|
@ -50,10 +52,23 @@ export default {
|
|||
this.recentEpisodes = episodePayload.episodes || []
|
||||
this.totalEpisodes = episodePayload.total
|
||||
this.currentPage = page
|
||||
},
|
||||
libraryChanged(libraryId) {
|
||||
if (libraryId !== this.loadedLibraryId) {
|
||||
if (this.$store.getters['libraries/getCurrentLibraryMediaType'] === 'podcast') {
|
||||
this.loadRecentEpisodes()
|
||||
} else {
|
||||
this.$router.replace('/bookshelf')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loadRecentEpisodes()
|
||||
this.$eventBus.$on('library-changed', this.libraryChanged)
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$eventBus.$off('library-changed', this.libraryChanged)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in a new issue