more use of RefreshItem where appropriate

This commit is contained in:
Drew Weymouth
2023-11-03 17:11:55 -07:00
parent 7e2cba3943
commit 2fb885142d
+15 -2
View File
@@ -251,15 +251,28 @@ func (t *Tracklist) SetSorting(sorting TracklistSort) {
t.hdr.SetSorting(ListHeaderSort{ColNumber: ColNumber(sorting.ColumnName), Type: sorting.SortOrder})
}
// Sets the currently playing track ID and updates the list rendering
func (t *Tracklist) SetNowPlaying(trackID string) {
prevNowPlaying := t.nowPlayingID
t.tracksMutex.RLock()
trPrev, idxPrev := t.findTrackByID(prevNowPlaying)
tr, idx := t.findTrackByID(trackID)
t.tracksMutex.RUnlock()
t.nowPlayingID = trackID
t.list.Refresh()
if trPrev != nil {
t.list.RefreshItem(idxPrev)
}
if tr != nil {
t.list.RefreshItem(idx)
}
}
// Increments the play count of the given track and updates the list rendering
func (t *Tracklist) IncrementPlayCount(trackID string) {
t.tracksMutex.RLock()
tr, idx := t.findTrackByID(trackID)
t.tracksMutex.RUnlock()
if tr, idx := t.findTrackByID(trackID); tr != nil {
if tr != nil {
tr.PlayCount += 1
t.list.RefreshItem(idx)
}