ensure play count in tracklist updates after scrobble

This commit is contained in:
Drew Weymouth
2023-02-13 17:04:47 -08:00
parent ed8efdf881
commit f7f6bcd546
8 changed files with 47 additions and 23 deletions
+15 -1
View File
@@ -105,6 +105,19 @@ func (t *Tracklist) SetNowPlaying(trackID string) {
t.list.Refresh()
}
func (t *Tracklist) IncrementPlayCount(track *subsonic.Child) {
if track == nil {
return
}
for _, tr := range t.Tracks {
if tr.ID == track.ID {
tr.PlayCount += 1
t.Refresh()
return
}
}
}
func (t *Tracklist) SelectAll() {
t.selectionMgr.SelectAll()
t.Refresh()
@@ -229,6 +242,7 @@ type TrackRow struct {
trackIdx int
trackID string
isPlaying bool
playCount int64
tappedAt int64 // unixMillis
num *widget.RichText
@@ -275,7 +289,7 @@ func NewTrackRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *TrackRow
}
func (t *TrackRow) Update(tr *subsonic.Child, isPlaying bool, rowNum int) {
if tr.ID == t.trackID && isPlaying == t.isPlaying {
if tr.ID == t.trackID && isPlaying == t.isPlaying && tr.PlayCount == t.playCount {
return
}
t.isPlaying = isPlaying