From 8a303f340b23eac144f934a7624bc05b34f877a1 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Fri, 26 Apr 2024 21:06:51 +0200 Subject: [PATCH] [web] Return the list itself when group operation is done --- web-src/src/lib/GroupedList.js | 1 + web-src/src/pages/PageAlbums.vue | 8 +++----- web-src/src/pages/PageArtist.vue | 7 +++---- web-src/src/pages/PageArtistTracks.vue | 7 +++---- web-src/src/pages/PageArtists.vue | 10 +++------- web-src/src/pages/PageComposerTracks.vue | 5 ++--- web-src/src/pages/PageGenreTracks.vue | 5 ++--- web-src/src/pages/PagePlaylistFolder.vue | 3 +-- 8 files changed, 18 insertions(+), 28 deletions(-) diff --git a/web-src/src/lib/GroupedList.js b/web-src/src/lib/GroupedList.js index 3cbedb84..19155398 100644 --- a/web-src/src/lib/GroupedList.js +++ b/web-src/src/lib/GroupedList.js @@ -101,6 +101,7 @@ export class GroupedList { }, new Map()) // Create index list this.indices = Array.from(this.itemsGrouped.keys()) + return this } *generate() { diff --git a/web-src/src/pages/PageAlbums.vue b/web-src/src/pages/PageAlbums.vue index a3b7b64c..d0a4a7f9 100644 --- a/web-src/src/pages/PageAlbums.vue +++ b/web-src/src/pages/PageAlbums.vue @@ -151,16 +151,14 @@ export default { computed: { albums() { - const grouping = this.groupings.find( + const { options } = this.groupings.find( (grouping) => grouping.id === this.selected_grouping_id ) - grouping.options.filters = [ + options.filters = [ (album) => !this.hide_singles || album.track_count > 2, (album) => !this.hide_spotify || album.data_kind !== 'spotify' ] - this.albums_list.group(grouping.options) - - return this.albums_list + return this.albums_list.group(options) }, hide_singles: { get() { diff --git a/web-src/src/pages/PageArtist.vue b/web-src/src/pages/PageArtist.vue index 51cc03d5..4a810eb8 100644 --- a/web-src/src/pages/PageArtist.vue +++ b/web-src/src/pages/PageArtist.vue @@ -130,14 +130,13 @@ export default { computed: { albums() { - const grouping = this.groupings.find( + const { options } = this.groupings.find( (grouping) => grouping.id === this.selected_grouping_id ) - grouping.options.filters = [ + options.filters = [ (album) => !this.hide_spotify || album.data_kind !== 'spotify' ] - this.albums_list.group(grouping.options) - return this.albums_list + return this.albums_list.group(options) }, hide_spotify: { get() { diff --git a/web-src/src/pages/PageArtistTracks.vue b/web-src/src/pages/PageArtistTracks.vue index 62f352b7..c08490dd 100644 --- a/web-src/src/pages/PageArtistTracks.vue +++ b/web-src/src/pages/PageArtistTracks.vue @@ -165,14 +165,13 @@ export default { return this.tracks_list.items.map((item) => item.uri).join() }, tracks() { - const grouping = this.groupings.find( + const { options } = this.groupings.find( (grouping) => grouping.id === this.selected_grouping_id ) - grouping.options.filters = [ + options.filters = [ (track) => !this.hide_spotify || track.data_kind !== 'spotify' ] - this.tracks_list.group(grouping.options) - return this.tracks_list + return this.tracks_list.group(options) } }, diff --git a/web-src/src/pages/PageArtists.vue b/web-src/src/pages/PageArtists.vue index 0b3134d3..5c29e211 100644 --- a/web-src/src/pages/PageArtists.vue +++ b/web-src/src/pages/PageArtists.vue @@ -122,19 +122,15 @@ export default { computed: { // Wraps GroupedList and updates it if filter or sort changes artists() { - if (!this.artists_list) { - return [] - } - const grouping = this.groupings.find( + const { options } = this.groupings.find( (grouping) => grouping.id === this.selected_grouping_id ) - grouping.options.filters = [ + options.filters = [ (artist) => !this.hide_singles || artist.track_count > artist.album_count * 2, (artist) => !this.hide_spotify || artist.data_kind !== 'spotify' ] - this.artists_list.group(grouping.options) - return this.artists_list + return this.artists_list.group(options) }, hide_singles: { get() { diff --git a/web-src/src/pages/PageComposerTracks.vue b/web-src/src/pages/PageComposerTracks.vue index a9b495b7..1fe9d021 100644 --- a/web-src/src/pages/PageComposerTracks.vue +++ b/web-src/src/pages/PageComposerTracks.vue @@ -135,11 +135,10 @@ export default { } }, tracks() { - const grouping = this.groupings.find( + const { options } = this.groupings.find( (grouping) => grouping.id === this.selected_grouping_id ) - this.tracks_list.group(grouping.options) - return this.tracks_list + return this.tracks_list.group(options) } }, diff --git a/web-src/src/pages/PageGenreTracks.vue b/web-src/src/pages/PageGenreTracks.vue index 27b51ea1..36e54d7d 100644 --- a/web-src/src/pages/PageGenreTracks.vue +++ b/web-src/src/pages/PageGenreTracks.vue @@ -131,11 +131,10 @@ export default { } }, tracks() { - const grouping = this.groupings.find( + const { options } = this.groupings.find( (grouping) => grouping.id === this.selected_grouping_id ) - this.tracks_list.group(grouping.options) - return this.tracks_list + return this.tracks_list.group(options) } }, diff --git a/web-src/src/pages/PagePlaylistFolder.vue b/web-src/src/pages/PagePlaylistFolder.vue index e2f55a5f..c2aafb08 100644 --- a/web-src/src/pages/PagePlaylistFolder.vue +++ b/web-src/src/pages/PagePlaylistFolder.vue @@ -66,7 +66,7 @@ export default { computed: { playlists() { - this.playlists_list.group({ + return this.playlists_list.group({ filters: [ (playlist) => playlist.folder || @@ -75,7 +75,6 @@ export default { playlist.item_count > playlist.stream_count ] }) - return this.playlists_list }, radio_playlists() { return this.$store.state.config.radio_playlists