From 18901a7c38e6e47674dba8c0be47eb77f85227d9 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Fri, 3 Apr 2020 14:48:31 -0400 Subject: [PATCH] Sort albums by artist Why wasn't I doing this before? --- Shared/MPDClient/Extensions/MPDClient+Album.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Shared/MPDClient/Extensions/MPDClient+Album.swift b/Shared/MPDClient/Extensions/MPDClient+Album.swift index 7c3a1bc..bf1e68c 100644 --- a/Shared/MPDClient/Extensions/MPDClient+Album.swift +++ b/Shared/MPDClient/Extensions/MPDClient+Album.swift @@ -57,7 +57,7 @@ extension MPDClient { func albums(filter: String) { var albums: [MPDAlbum] = [] - mpd_search_db_songs(self.connection, false) + mpd_search_db_songs(connection, false) if filter != "" { let escapedFilter = filter.replacingOccurrences(of: "'", with: "\\'") @@ -66,11 +66,12 @@ extension MPDClient { "(any contains '\(escapedFilter)')" ) } - mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1") + mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1") + mpd_search_add_sort_tag(connection, MPD_TAG_ALBUM_ARTIST_SORT, false) mpd_search_commit(self.connection) - while let song = mpd_recv_song(self.connection) { + while let song = mpd_recv_song(connection) { let mpdSong = MPDSong(song) let mpdAlbum = MPDAlbum( @@ -92,10 +93,10 @@ extension MPDClient { var firstSong: MPDSong? - mpd_search_db_songs(self.connection, true) - mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album.title) - mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM_ARTIST, album.artist) - mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1") + mpd_search_db_songs(connection, true) + mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album.title) + mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM_ARTIST, album.artist) + mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, MPD_TAG_TRACK, "1") mpd_search_commit(self.connection)