Playlists library; Local playlist loading dud tracks

This commit is contained in:
James Barnsley
2016-11-10 10:26:15 +13:00
parent 5bd6a6bbcc
commit a1bb8bf7d4
9 changed files with 70 additions and 74 deletions

View File

@ -206,8 +206,8 @@ const MopidyMiddleware = (function(){
},
response,
{
tracks: response.tracks,
total_tracks: response.tracks.length
tracks: ( response.tracks ? response.tracks : [] ),
tracks_total: ( response.tracks ? response.tracks.length : 0 )
}
)
@ -223,17 +223,19 @@ const MopidyMiddleware = (function(){
if (response.hasOwnProperty(uri)) {
var track = response[uri][0];
// find the track reference, and drop in the full track data
function getByURI( trackReference ){
return track.uri == trackReference.uri
}
var trackReferences = playlist.tracks.filter(getByURI);
// there could be multiple instances of this track, so accommodate this
for( var j = 0; j < trackReferences.length; j++){
var key = playlist.tracks.indexOf( trackReferences[j] );
playlist.tracks[ key ] = track;
if( track ){
// find the track reference, and drop in the full track data
function getByURI( trackReference ){
return track.uri == trackReference.uri
}
var trackReferences = playlist.tracks.filter(getByURI);
// there could be multiple instances of this track, so accommodate this
for( var j = 0; j < trackReferences.length; j++){
var key = playlist.tracks.indexOf( trackReferences[j] );
playlist.tracks[ key ] = track;
}
}
}
}

View File

@ -67,10 +67,6 @@ export default function reducer(mopidy = {}, action){
* Asset-oriented actions
**/
case 'MOPIDY_PLAYLISTS_LOADED':
if( !action.data ) return mopidy;
return Object.assign({}, mopidy, { playlists: action.data });
case 'MOPIDY_DIRECTORY_LOADED':
return Object.assign({}, mopidy, {
directory: action.data