Mopidy album too

This commit is contained in:
James Barnsley
2016-11-09 20:38:08 +13:00
parent 3e15aa7f1d
commit b18b1fa2b7
3 changed files with 26 additions and 25 deletions

View File

@ -240,17 +240,20 @@ const MopidyMiddleware = (function(){
//store.dispatch({ type: 'MOPIDY_ALBUM_LOADED', data: false });
instruct( socket, store, 'library.lookup', action.data )
.then( response => {
var album = response[0].album;
album.artists = response[0].artists;
if( !album.images ) album.images = []
album.tracks = {
items: response,
total: response.length
}
var album = Object.assign(
{},
{ images: [] },
response[0].album,
{
artists: response[0].artists,
tracks: response,
tracks_total: response.length
}
)
var uris = [];
for( var i = 0; i < album.tracks.items.length; i++ ){
uris.push( album.tracks.items[i].uri );
for( var i = 0; i < album.tracks.length; i++ ){
uris.push( album.tracks[i].uri );
}
// load artwork from LastFM
@ -276,12 +279,12 @@ const MopidyMiddleware = (function(){
function getByURI( trackReference ){
return track.uri == trackReference.uri
}
var trackReferences = album.tracks.items.filter(getByURI);
var trackReferences = album.tracks.filter(getByURI);
// there could be multiple instances of this track, so accommodate this
for( var j = 0; j < trackReferences.length; j++){
var key = album.tracks.items.indexOf( trackReferences[j] );
album.tracks.items[ key ] = track;
var key = album.tracks.indexOf( trackReferences[j] );
album.tracks[ key ] = track;
}
}
}