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.
For the scenarios where both `Filter` and `Map` are being applied,
having this util should be faster, as it avoids the creation of an extra
slice during the intermediate step.
Having a `slices.Contains` check within a `for` loop has a complexity of
`O(n*m)`, with a worst case scenario of `O(n^2)` for when both
collections have the same size.
This is because `slices.Contains` internally runs just a regular loop,
checking for equality element by element.
Instead, this diff changes every occurence of this pattern to converting
the collection we compare against to a set, and then running a faster
lookup against it.
The Grid view and related components were highly coupled to Albums,
including the filter button that is currently used only for album
filtering.
As part of the migration of Artists to Grid view, this is the smallest
possible change to convert many of the existing code to
generics/interfaces that will allow different media to be displayed and
filtered by using Grid views.
The main changes in this diff are:
* Introduction of generics for Media types (`M`) and Filter options
(`F`), which can be later extended to other entities besides Albums.
* Complete decoupling of `GridViewPage` and related components from
Albums (making these pages also generic).
* Refactoring of Subsonic/Jellyfin specific code to understand these new
generics when dealing with filtering logic.
Upgrade to 1.21 as 1.20 is now unmaintained.
Most changes are related to the new `slices` package from standard
library, which can replace some existing custom functions.
This feature is only available on the Subsonic media provider. Using a
Jellyfin server will make Supersonic hide the "Share" option.
* Artists: Option available in grid view and in Artist view.
* Albums: Option available in grid view and in Album view.
* Tracks: Option available in tracklist, when a single track is selected.
Loop mode changes were being correctly reflected in Supersonic, when
updated in the toolbar, but not the other way around. We were only
missing an `Options` changes emit when loop mode is changed in
Supersonic.
Problem:
When changing tracks, the toolbar display on Linux sometimes misses the
track cover art, and displays a placeholder instead.
Solution:
Copy same callback as the one used for MacOS, which calls
`GetCoverArtUrl` first, to avoid missing cover arts.
Problem:
The operating system toolbar's component to control Supersonic playback
had its Seek functionality broken on Linux. When playing a song, seeking
for a different position from Supersonic worked as expected, but seeking
from the toolbar did nothing to the current track.
I found that the underlying reason was in `MPRISHandler.SetPosition`, as
the `if m.curTrackPath == trackId` always returned false.
`m.curTrackPath` was the right value, but `trackId` was wrong: On the
first song being played for a tracklist, `trackId` when trying to seek
was set to `/org/mpris/MediaPlayer2/TrackList/NoTrack`. When moving to
the next song, `trackId` then became the Track ID of the previously
played song.
Solution:
Changing the call to `OnTitle()` is enough to fix the issue, as the
MPRIS `Metadata()` generation depends on the value of `m.curTrackPath`.
Because it was being called before changing its value, the received
`trackId` was always off.
This is being added, because testing the latest `develop` version for
`fyne` fails with the following error:
```
ui/widgets/imageplaceholder.go:48:3: cannot use i.imageDisp (variable of type *TappableImage) as fyne.CanvasObject value in argument to container.NewMax: *TappableImage does not implement fyne.CanvasObject (missing method MinSize)
ui/widgets/nowplayingcard.go:51:33: cannot use n.cover (variable of type *TappableImage) as fyne.CanvasObject value in argument to container.NewBorder: *TappableImage does not implement fyne.CanvasObject (missing method MinSize)
ui/widgets/tappablewrappers.go:64:21: cannot use t (variable of type *TappableImage) as fyne.Widget value in argument to t.ExtendBaseWidget: *TappableImage does not implement fyne.Widget (missing method MinSize)
```
This new Loop mode keeps reproducing the current track, unless it is
changed using the player controls to go to the next/previous track.
As in other applications, this is set by using the "Repeat" button,
which now goes from "Off" -> "Repeat All" -> "Repeat One".
Adding the Loop functionality, along with the Player changes to support
it, and a button to the player controls.
`Player` now has a `loopMode` attribute, which determines whether it
should loop. At the moment, only the following modes are supported:
* `LoopNone`: Disables loop.
* `LoopAll`: Enables loop for the entire playlist queue.
This has been designed as an enum, to support other modes in the future
(e.g. loop for the current track only).
It depends on the `loop` functionality provided by MPV (using the
[`loop-playlist` option](https://mpv.io/manual/master/#options-loop-playlist)),
so no custom logic is needed to reset the currently playing index.
According to the official
[migration guide](https://github.com/pelletier/go-toml/tree/v2#migrating-from-v1),
there are no breaking changes that could affect this project.
Main differences are:
* `Default struct fields order`: Struct fields stop being alphabetically
sorted, unless their sorting is changed in the struct definitions. Shouldn't be
relevant.
* `No indentation by default`: Also not relevant for newly generated
configuration files. Doesn't break reading existing configuration
files.
This change fixes two `TODO` comments, by scrobbling the currently
playing track if it's removed from the queue, and only run OnSongChange
callbacks when the playing track is affected.