Skip to content

Commit

Permalink
fix bugs with reordering playlist tracks multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jun 23, 2024
1 parent 0d97e67 commit ee38c36
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ui/browsing/playlistpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,20 @@ func (a *PlaylistPage) doSetNewTrackOrder(ids []string, newPos int) {
}
}
newTracks := sharedutil.ReorderItems(a.tracks, idxs, newPos)
ids = sharedutil.TracksToIDs(newTracks)
if err := a.sm.Server.ReplacePlaylistTracks(a.playlistID, ids); err != nil {
log.Printf("error updating playlist: %s", err.Error())
} else {
renumberTracks(newTracks)
// force-switch back to unsorted view to show new track order
a.tracklist.SetSorting(widgets.TracklistSort{})
a.tracklist.SetTracks(newTracks)
a.tracklist.UnselectAll()
}
// we can't block the UI waiting for the server so assume it will succeed
go func() {
ids = sharedutil.TracksToIDs(newTracks)
if err := a.sm.Server.ReplacePlaylistTracks(a.playlistID, ids); err != nil {
log.Printf("error updating playlist: %s", err.Error())
}
}()

renumberTracks(newTracks)
// force-switch back to unsorted view to show new track order
a.tracklist.SetSorting(widgets.TracklistSort{})
a.tracklist.SetTracks(newTracks)
a.tracklist.UnselectAll()
a.tracks = newTracks
}

func (a *PlaylistPage) onRemoveSelectedFromPlaylist() {
Expand Down

0 comments on commit ee38c36

Please sign in to comment.