Skip to content

Commit

Permalink
Fix #515: remove correct tracks from playlist when sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Dec 27, 2024
1 parent 268e847 commit 5d72403
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions ui/widgets/tracklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,21 +699,11 @@ func (t *Tracklist) SelectedTrackIndexes() []int {
t.tracksMutex.RLock()
defer t.tracksMutex.RUnlock()

if t.sorting.SortOrder == SortNone {
idx := -1
return sharedutil.FilterMapSlice(t.tracks, func(t *util.TrackListModel) (int, bool) {
idx++
return idx, t.Selected
})
}
ids := sharedutil.ToSet(util.SelectedItemIDs(t.tracks))
idxs := make([]int, 0, len(ids))
for id := range ids {
idxs = append(idxs, slices.IndexFunc(t.tracks, func(t *util.TrackListModel) bool {
return t.Item.Metadata().ID == id
}))
}
return idxs
idx := -1
return sharedutil.FilterMapSlice(t.tracksOrigOrder, func(t *util.TrackListModel) (int, bool) {
idx++
return idx, t.Selected
})
}

func (t *Tracklist) lenTracks() int {
Expand Down

0 comments on commit 5d72403

Please sign in to comment.