Merging playlists by uri; Hide context on scroll
This commit is contained in:
@ -588,6 +588,19 @@ export function toggleFollowingPlaylist( uri, method ){
|
||||
}
|
||||
}
|
||||
|
||||
export function addTracksToPlaylist( playlist_uri, tracks_uris ){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest( dispatch, getState, 'users/'+ helpers.getFromUri('userid',playlist_uri) + '/playlists/'+ helpers.getFromUri('playlistid',playlist_uri) + '/tracks', 'POST', { uris: tracks_uris } )
|
||||
.then( response => {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_TRACKS_ADDED',
|
||||
tracks_uris: tracks_uris,
|
||||
snapshot_id: response.snapshot_id
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function deleteTracksFromPlaylist( uri, snapshot_id, tracks_indexes ){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest( dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri) + '/playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'DELETE', { snapshot_id: snapshot_id, positions: tracks_indexes } )
|
||||
|
||||
@ -24,12 +24,22 @@ const SpotifyMiddleware = (function(){
|
||||
return
|
||||
}
|
||||
if( !store.getState().spotify.me || store.getState().spotify.me.id != playlist.owner.id ){
|
||||
alert('You can only modify tracks you own')
|
||||
alert('You can only modify playlists you own')
|
||||
return
|
||||
}
|
||||
store.dispatch( actions.deleteTracksFromPlaylist( playlist.uri, playlist.snapshot_id, action.tracks_indexes ))
|
||||
break
|
||||
|
||||
|
||||
case 'SPOTIFY_ADD_PLAYLIST_TRACKS':
|
||||
|
||||
if( !store.getState().spotify.authorized ){
|
||||
alert('Must be logged in to Spotify to do this')
|
||||
return
|
||||
}
|
||||
store.dispatch( actions.addTracksToPlaylist( action.playlist_uri, action.tracks_uris ))
|
||||
break
|
||||
|
||||
// when our mopidy server current track changes
|
||||
case 'MOPIDY_CURRENTTLTRACK':
|
||||
|
||||
|
||||
Reference in New Issue
Block a user