Editing playlist description; Handling change of local playlist URIs

This commit is contained in:
James Barnsley
2017-07-13 07:53:00 +12:00
parent eabdec24cc
commit f272c6f733
8 changed files with 127 additions and 50 deletions

View File

@ -130,7 +130,7 @@ export function reorderPlaylistTracks( uri, indexes, insert_before, snapshot_id
}
}
export function savePlaylist( uri, name, is_public = false ){
export function savePlaylist(uri, name, is_public = false, description = ''){
switch( helpers.uriSource( uri ) ){
case 'spotify':
@ -138,7 +138,8 @@ export function savePlaylist( uri, name, is_public = false ){
type: 'SPOTIFY_SAVE_PLAYLIST',
key: uri,
name: name,
is_public: is_public
is_public: is_public,
description: (description == '' ? null : description)
}
case 'm3u':

View File

@ -471,7 +471,22 @@ export default function reducer(ui = {}, action){
}
playlists[action.key] = merged_playlist
return Object.assign({}, ui, { playlists: playlists });
return Object.assign({}, ui, { playlists: playlists })
case 'PLAYLIST_KEY_UPDATED':
var playlists = Object.assign([], ui.playlists)
// URI not in our index? No change needed then
if (typeof(playlists[action.key]) === 'undefined'){
return ui
}
// Delete our old playlist by key, and add by new key
var playlist = Object.assign({}, playlists[action.key])
delete playlists[action.key]
playlists[playlist.uri] = playlist
return Object.assign({}, ui, { playlists: playlists })
case 'PLAYLISTS_LOADED':
var playlists = Object.assign([], ui.playlists)