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
This commit is contained in:
LJ
2026-08-28 13:03:59 -06:00
parent 12025ab59a
commit 4a1cf0ea4a
2 changed files with 20 additions and 1 deletions
+13 -1
View File
@@ -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)
}
}
</script>
+7
View File
@@ -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)
}