Tracklists are sortable with ONLY the first bunch; Playlist and queue sorting

This commit is contained in:
James Barnsley
2016-11-16 16:30:49 +13:00
parent 86b9665ec8
commit 04abfe6f2b
7 changed files with 87 additions and 28 deletions

View File

@ -641,17 +641,15 @@ export function deleteTracksFromPlaylist( uri, snapshot_id, tracks_indexes ){
}
}
export function reorderPlaylistTracks( uri, indexes, to_index, snapshot_id ){
var range_start = indexes[0]
var range_length = indexes.length
export function reorderPlaylistTracks( uri, range_start, range_length, insert_before, snapshot_id ){
return (dispatch, getState) => {
sendRequest( dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri) + '/playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'PUT', { uri: uri, range_start: range_start, range_length: range_length, insert_before: to_index, snapshot_id: snapshot_id } )
sendRequest( dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri) + '/playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'PUT', { uri: uri, range_start: range_start, range_length: range_length, insert_before: insert_before, snapshot_id: snapshot_id } )
.then( response => {
dispatch({
type: 'PLAYLIST_TRACKS_REORDERED',
range_start: range_start,
range_length: range_length,
to_index: to_index,
insert_before: insert_before,
snapshot_id: response.snapshot_id
});
});

View File

@ -58,7 +58,7 @@ const SpotifyMiddleware = (function(){
alert('Must be logged in to Spotify to do this')
return
}
store.dispatch( actions.reorderPlaylistTracks( action.uri, action.indexes, action.to_index ))
store.dispatch( actions.reorderPlaylistTracks( action.uri, action.range_start, action.range_length, action.insert_before, action.snapshot_id ))
break