Playlist editability with new playlist format

This commit is contained in:
James Barnsley
2018-09-14 16:11:55 +12:00
parent d733f5554c
commit f66b33c3e4
10 changed files with 30 additions and 28 deletions

View File

@ -271,29 +271,31 @@ class ContextMenu extends React.Component{
}
goToArtist(e){
if (!this.props.menu.items || this.props.menu.items.length <= 0 || !this.props.menu.items[0].artists || this.props.menu.items[0].artists.length <= 0){
if (!this.props.menu.items || this.props.menu.items.length <= 0 || !this.props.menu.items[0].artists_uris || this.props.menu.items[0].artists_uris.length <= 0){
return null;
} else {
this.props.uiActions.hideContextMenu();
hashHistory.push(global.baseURL +'artist/'+ this.props.menu.items[0].artists[0].uri);
// note: we can only go to one artist (even if this item has multiple artists, just go to the first one)
hashHistory.push(global.baseURL +'artist/'+ this.props.menu.items[0].artists_uris[0]);
}
}
goToAlbum(e){
if (!this.props.menu.items || this.props.menu.items.length <= 0 || !this.props.menu.items[0].album){
if (!this.props.menu.items || this.props.menu.items.length <= 0 || !this.props.menu.items[0].album_uri){
return null;
} else {
this.props.uiActions.hideContextMenu();
hashHistory.push(global.baseURL +'album/'+ this.props.menu.items[0].album.uri);
hashHistory.push(global.baseURL +'album/'+ this.props.menu.items[0].album_uri);
}
}
goToUser(e){
if (!this.props.menu.items || this.props.menu.items.length <= 0){
if (!this.props.menu.items || this.props.menu.items.length <= 0 || !this.props.menu.items[0].user_uri){
return null;
} else {
this.props.uiActions.hideContextMenu();
hashHistory.push(global.baseURL +'user/'+ this.props.menu.items[0].owner.uri);
hashHistory.push(global.baseURL +'user/'+ this.props.menu.items[0].user_uri);
}
}

View File

@ -474,7 +474,7 @@ export let formatPlaylist = function(data){
playlist.images = formatImages(playlist.images);
}
if (data.followers && data.followers.total){
if (data.followers && data.followers.total !== undefined){
playlist.followers = data.followers.total;
}
@ -484,6 +484,7 @@ export let formatPlaylist = function(data){
uri: data.owner.uri,
name: (data.owner.display_name ? data.owner.display_name : null)
}
playlist.user_uri = data.owner.uri;
}
// Spotify upgraded their playlists URI to remove user component (Sept 2018)

View File

@ -673,7 +673,7 @@ const CoreMiddleware = (function(){
case 'spotify':
if (store.getState().spotify.authorization && store.getState().spotify.me){
playlist.can_edit = (helpers.getFromUri('playlistowner',playlist.uri) == store.getState().spotify.me.id)
playlist.can_edit = (playlist.owner.id == store.getState().spotify.me.id)
}
}

View File

@ -112,7 +112,7 @@ const localstorageMiddleware = (function(){
helpers.setStorage(
'spotify',
{
me: action.data
me: action.me
}
);
break;

View File

@ -1730,7 +1730,6 @@ const MopidyMiddleware = (function(){
var uris_to_load = uris.splice(0,50);
if (uris_to_load.length > 0){
console.log(uris.length);
store.dispatch(uiActions.updateProcess(
'MOPIDY_LIBRARY_ALBUMS_PROCESSOR',
'Loading '+uris.length+' local albums',

View File

@ -1491,7 +1491,6 @@ export function getPlaylist(uri){
helpers.formatPlaylist(response),
{
is_completely_loaded: true,
can_edit: (getState().spotify.me && response.owner.id == getState().spotify.me.id),
user_uri: response.owner.uri,
tracks_uris: helpers.arrayOf('uri', tracks),
tracks_more: response.tracks.next,
@ -1500,7 +1499,7 @@ export function getPlaylist(uri){
}
)
//dispatch(coreActions.userLoaded(helpers.formatUser(response.owner)));
dispatch(coreActions.userLoaded(helpers.formatUser(response.owner)));
dispatch(coreActions.tracksLoaded(tracks));
dispatch(coreActions.playlistLoaded(playlist));
},

View File

@ -199,7 +199,7 @@ class Playlist extends React.Component{
<ul className="details">
{!this.props.slim_mode ? <li className="has-tooltip"><Icon type="fontawesome" name={helpers.sourceIcon(playlist.uri)} /><span className="tooltip">{helpers.uriSource(playlist.uri)} playlist</span></li> : null }
{playlist.user_uri && !this.props.slim_mode ? <li><URILink type="user" uri={playlist.user_uri}>{playlist.user ? playlist.user.name : helpers.getFromUri('userid',playlist.user_uri)}</URILink></li> : null }
{playlist.followers ? <li>{playlist.followers.toLocaleString()} followers</li> : null }
{playlist.followers !== undefined ? <li>{playlist.followers.toLocaleString()} followers</li> : null }
{playlist.last_modified_date ? <li>Edited <Dater type="ago" data={playlist.last_modified_date} /></li> : null }
<li>
{playlist.tracks_total ? playlist.tracks_total : (playlist.tracks ? playlist.tracks.length : '0')} tracks,&nbsp;