Mopidy artist

This commit is contained in:
James Barnsley
2016-11-01 16:41:04 +13:00
parent 5ccd9b48a0
commit 1738c2a29b
15 changed files with 2403 additions and 2172 deletions

View File

@ -199,6 +199,7 @@ const MopidyMiddleware = (function(){
instruct( socket, store, 'library.lookup', action.data )
.then( response => {
var album = response[0].album;
album.artists = response[0].artists;
album.tracks = {
items: response,
total: response.length
@ -236,6 +237,32 @@ const MopidyMiddleware = (function(){
})
break;
case 'MOPIDY_ARTIST':
instruct( socket, store, 'library.lookup', action.data )
.then( response => {
var artist = {
name: 'yeah',
images: [],
albums: [],
tracks: response.slice(0,10)
}
for( var i = 0; i < response.length; i++ ){
var album = response[i].album;
function getByURI( albumToCheck ){
return album.uri == albumToCheck.uri
}
var existingAlbum = artist.albums.find(getByURI);
if( !existingAlbum ){
artist.albums.push(album)
}
}
store.dispatch({ type: 'MOPIDY_ARTIST_LOADED', data: artist });
})
break;
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);