misc: Migrate Artists page to GridView

Remove custom page implementation for Artists, and instead rely on the
generic `GridView` approach. This also simplifies adding new
sorting/filtering options as next improvements.

The new `ArtistFilter` is a dummy implementation without any real
filters at the moment.

Also, the `go-jellyfin` upgrade is needed to correctly display the album
count for each artist.
This commit is contained in:
Michael Manganiello
2024-03-30 12:42:48 -03:00
parent b7e7e959ff
commit 66658b1401
12 changed files with 254 additions and 220 deletions
+25
View File
@@ -2,6 +2,7 @@ package widgets
import (
"context"
"fmt"
"math"
"sync"
@@ -65,6 +66,30 @@ func NewGridViewAlbumIterator(iter mediaprovider.AlbumIterator) GridViewIterator
return gridViewAlbumIterator{iter: NewBatchingIterator(iter)}
}
type gridViewArtistIterator struct {
iter BatchingIterator[mediaprovider.Artist]
}
func (g gridViewArtistIterator) NextN(n int) []GridViewItemModel {
artists := g.iter.NextN(n)
return sharedutil.MapSlice(artists, func(ar *mediaprovider.Artist) GridViewItemModel {
albumsLabel := "albums"
if ar.AlbumCount == 1 {
albumsLabel = "album"
}
return GridViewItemModel{
Name: ar.Name,
ID: ar.ID,
CoverArtID: ar.CoverArtID,
Secondary: []string{fmt.Sprintf("%d %s", ar.AlbumCount, albumsLabel)},
}
})
}
func NewGridViewArtistIterator(iter mediaprovider.ArtistIterator) GridViewIterator {
return gridViewArtistIterator{iter: NewBatchingIterator(iter)}
}
type GridView struct {
widget.BaseWidget