Fix #421: properly handle reordering and deleting repeat tracks in queue

This commit is contained in:
Drew Weymouth
2024-07-13 10:53:57 -07:00
parent 69a1900cb5
commit 3f30448383
5 changed files with 30 additions and 21 deletions
+3 -10
View File
@@ -144,9 +144,9 @@ func NewNowPlayingPage(
a.queueList.OnShowArtistPage = func(artistID string) {
a.contr.NavigateTo(controller.ArtistRoute(artistID))
}
a.queueList.OnRemoveFromQueue = func(trackIDs []string) {
a.queueList.OnRemoveFromQueue = func(idxs []int) {
a.queueList.UnselectAll()
a.pm.RemoveTracksFromQueue(trackIDs)
a.pm.RemoveTracksFromQueue(idxs)
}
a.queueList.OnSetRating = func(trackIDs []string, rating int) {
contr.SetTrackRatings(trackIDs, rating)
@@ -515,14 +515,7 @@ func (a *NowPlayingPage) Refresh() {
a.BaseWidget.Refresh()
}
func (a *NowPlayingPage) doSetNewTrackOrder(trackIDs []string, insertPos int) {
trackIDSet := sharedutil.ToSet(trackIDs)
idxs := make([]int, 0, len(trackIDs))
for i, tr := range a.queue {
if _, ok := trackIDSet[tr.Metadata().ID]; ok {
idxs = append(idxs, i)
}
}
func (a *NowPlayingPage) doSetNewTrackOrder(idxs []int, insertPos int) {
newTracks := sharedutil.ReorderItems(a.queue, idxs, insertPos)
a.pm.UpdatePlayQueue(newTracks)
}