From 4a1cf0ea4a36664c4c9c19076630e5cb64bf1d9d Mon Sep 17 00:00:00 2001 From: LJ Date: Fri, 28 Aug 2026 13:03:59 -0600 Subject: [PATCH] Leave playlist/collection detail pages when the library changes (#1711, #1712) The item detail page already listens for the app-wide `library-changed` event and navigates away; the playlist and collection detail pages did not, so switching libraries left them showing stale content with no way back to the list. - playlist/_id.vue: route to /bookshelf/playlists on library change - collection/_id.vue: route to /bookshelf/collections unless the new library is the collection's own library --- pages/collection/_id.vue | 14 +++++++++++++- pages/playlist/_id.vue | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pages/collection/_id.vue b/pages/collection/_id.vue index 9f371c66..c4c5b188 100644 --- a/pages/collection/_id.vue +++ b/pages/collection/_id.vue @@ -135,8 +135,20 @@ export default { this.$eventBus.$emit('play-item', { libraryItemId: nextBookNotRead.id }) } } + }, + libraryChanged(libraryId) { + // A collection belongs to a single library, so leave this page when a different library is + // selected rather than showing a collection that is not in the current library + if (!libraryId || libraryId !== this.collection.libraryId) { + this.$router.replace('/bookshelf/collections') + } } }, - mounted() {} + mounted() { + this.$eventBus.$on('library-changed', this.libraryChanged) + }, + beforeDestroy() { + this.$eventBus.$off('library-changed', this.libraryChanged) + } } diff --git a/pages/playlist/_id.vue b/pages/playlist/_id.vue index 6f84cc8b..077b9ebc 100644 --- a/pages/playlist/_id.vue +++ b/pages/playlist/_id.vue @@ -162,13 +162,20 @@ export default { if (this.playlist.id === playlist.id) { this.$router.replace('/bookshelf/playlists') } + }, + libraryChanged() { + // Playlist contents are shown in the context of the selected library, so leave this page + // when the library changes rather than showing stale items + this.$router.replace('/bookshelf/playlists') } }, mounted() { + this.$eventBus.$on('library-changed', this.libraryChanged) this.$socket.$on('playlist_updated', this.playlistUpdated) this.$socket.$on('playlist_removed', this.playlistRemoved) }, beforeDestroy() { + this.$eventBus.$off('library-changed', this.libraryChanged) this.$socket.$off('playlist_updated', this.playlistUpdated) this.$socket.$off('playlist_removed', this.playlistRemoved) }