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