From d681d87b31b621f7ed41f493fb67c467f77770a6 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sun, 25 Jan 2026 09:00:28 -0800 Subject: [PATCH] Discussion #485: use SortName when sorting artist's albums by name --- backend/mediaprovider/model.go | 1 + backend/mediaprovider/subsonic/subsonicmediaprovider.go | 1 + go.mod | 2 +- go.sum | 4 ++-- ui/browsing/artistpage.go | 8 +++++++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/mediaprovider/model.go b/backend/mediaprovider/model.go index df08a0d..238ccb4 100644 --- a/backend/mediaprovider/model.go +++ b/backend/mediaprovider/model.go @@ -67,6 +67,7 @@ type Album struct { ID string CoverArtID string Name string + SortName string Duration time.Duration ArtistIDs []string ArtistNames []string diff --git a/backend/mediaprovider/subsonic/subsonicmediaprovider.go b/backend/mediaprovider/subsonic/subsonicmediaprovider.go index b7c9c61..7a4f1bd 100644 --- a/backend/mediaprovider/subsonic/subsonicmediaprovider.go +++ b/backend/mediaprovider/subsonic/subsonicmediaprovider.go @@ -667,6 +667,7 @@ func fillAlbum(subAlbum *subsonic.AlbumID3, album *mediaprovider.Album) { album.ID = subAlbum.ID album.CoverArtID = subAlbum.CoverArt album.Name = subAlbum.Name + album.SortName = subAlbum.SortName album.Duration = time.Duration(subAlbum.Duration) * time.Second album.ArtistIDs = artistIDs album.ArtistNames = artistNames diff --git a/go.mod b/go.mod index e585fb9..f0bb9f5 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/quarckster/go-mpris-server v1.0.3 github.com/supersonic-app/fyne-lyrics v0.0.0-20250614151306-b1880a70a410 github.com/supersonic-app/go-mpv v0.1.1-0.20250822102843-7a8cde5f5449 - github.com/supersonic-app/go-subsonic v0.0.0-20250917154259-2bbe535cf8f3 + github.com/supersonic-app/go-subsonic v0.0.0-20260125165421-1efaa048a150 github.com/supersonic-app/go-upnpcast v0.0.0-20250330154256-b957204209a5 github.com/zalando/go-keyring v0.2.6 golang.org/x/net v0.38.0 diff --git a/go.sum b/go.sum index 991f2e8..d2d30e2 100644 --- a/go.sum +++ b/go.sum @@ -134,8 +134,8 @@ github.com/supersonic-app/go-glfw/v3.3/glfw v0.0.0-20250906235349-c09e5a2f6b75 h github.com/supersonic-app/go-glfw/v3.3/glfw v0.0.0-20250906235349-c09e5a2f6b75/go.mod h1:SyRD8YfuKk+ZXlDqYiqe1qMSqjNgtHzBTG810KUagMc= github.com/supersonic-app/go-mpv v0.1.1-0.20250822102843-7a8cde5f5449 h1:UHIPI43VzyWuIF8z8WVMdjMsC/orZTZQJraD/Iv+ghw= github.com/supersonic-app/go-mpv v0.1.1-0.20250822102843-7a8cde5f5449/go.mod h1:1bQz6kBQumJopXEbkiqoLxIXLy7F7yWFBvknvpAtIC0= -github.com/supersonic-app/go-subsonic v0.0.0-20250917154259-2bbe535cf8f3 h1:RuCWkkDc0THP9Y5wbPG8q0Or5zT5cxfLdVzznX+hXbA= -github.com/supersonic-app/go-subsonic v0.0.0-20250917154259-2bbe535cf8f3/go.mod h1:ClhAgC2qobwH19D6kdwULLYSHlOmldDGkdu2G2Z0Ijo= +github.com/supersonic-app/go-subsonic v0.0.0-20260125165421-1efaa048a150 h1:Wh3EUdJI8bSr2nYtnkmG+bGNzEtGGSW3Rcg4eDM1a0M= +github.com/supersonic-app/go-subsonic v0.0.0-20260125165421-1efaa048a150/go.mod h1:ClhAgC2qobwH19D6kdwULLYSHlOmldDGkdu2G2Z0Ijo= github.com/supersonic-app/go-upnpcast v0.0.0-20250330154256-b957204209a5 h1:aoUJKPFD/ZrNZjK6fl2Xhazwsttx42esKxhSSzEE3Bo= github.com/supersonic-app/go-upnpcast v0.0.0-20250330154256-b957204209a5/go.mod h1:ibt19zDV5/vvF14jHJpTv3AOorq1EbmrMAubxnuvR5Y= github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index 9989db0..ebabfc3 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -276,7 +276,13 @@ func (a *ArtistPage) sortAlbumsSlices(slices ...[]*mediaprovider.Album) { } case discographySorts[2]: /*name*/ sortFunc = func(x, y int) bool { - return curSlice[x].Name < curSlice[y].Name + sortStr := func(a *mediaprovider.Album) string { + if a.SortName != "" { + return a.SortName + } + return a.Name + } + return sortStr(curSlice[x]) < sortStr(curSlice[y]) } }