Converting to base64
This commit is contained in:
@ -1488,7 +1488,7 @@ export function createPlaylist(name, description, is_public, is_collaborative){
|
||||
}
|
||||
}
|
||||
|
||||
export function savePlaylist(uri, name, description, is_public, is_collaborative){
|
||||
export function savePlaylist(uri, name, description, is_public, is_collaborative, image){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
var data = {
|
||||
@ -1498,20 +1498,51 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
collaborative: is_collaborative
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri), 'PUT', data)
|
||||
// Update the playlist fields
|
||||
sendRequest(
|
||||
dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri), 'PUT', data)
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_UPDATED',
|
||||
key: uri,
|
||||
playlist: {
|
||||
name: name,
|
||||
public: is_public,
|
||||
collaborative: is_collaborative,
|
||||
description: description
|
||||
}
|
||||
})
|
||||
dispatch(uiActions.createNotification({content: 'Saved'}));
|
||||
|
||||
// Save the image
|
||||
if (image){
|
||||
sendRequest(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri)+'/image', 'PUT', image)
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_UPDATED',
|
||||
key: uri,
|
||||
playlist: {
|
||||
name: name,
|
||||
public: is_public,
|
||||
collaborative: is_collaborative,
|
||||
description: description,
|
||||
image: image
|
||||
}
|
||||
});
|
||||
},
|
||||
error => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not save image',
|
||||
error
|
||||
));
|
||||
}
|
||||
);
|
||||
|
||||
// No image, so we're done here
|
||||
} else {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_UPDATED',
|
||||
key: uri,
|
||||
playlist: {
|
||||
name: name,
|
||||
public: is_public,
|
||||
collaborative: is_collaborative,
|
||||
description: description
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error => {
|
||||
dispatch(coreActions.handleException(
|
||||
@ -1519,7 +1550,7 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
error
|
||||
));
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -92,14 +92,12 @@ const SpotifyMiddleware = (function(){
|
||||
store.dispatch(spotifyActions.addTracksToPlaylist(action.key, action.tracks_uris ))
|
||||
break;
|
||||
|
||||
|
||||
case 'SPOTIFY_REORDER_PLAYLIST_TRACKS':
|
||||
store.dispatch(spotifyActions.reorderPlaylistTracks(action.key, action.range_start, action.range_length, action.insert_before, action.snapshot_id ))
|
||||
break;
|
||||
|
||||
|
||||
case 'SPOTIFY_SAVE_PLAYLIST':
|
||||
store.dispatch(spotifyActions.savePlaylist(action.key, action.name, action.description, action.is_public, action.is_collaborative ))
|
||||
store.dispatch(spotifyActions.savePlaylist(action.key, action.name, action.description, action.is_public, action.is_collaborative, action.image))
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_NEW_RELEASES_LOADED':
|
||||
|
||||
Reference in New Issue
Block a user