local artists

This commit is contained in:
James Barnsley
2016-11-01 19:27:59 +13:00
parent 1738c2a29b
commit 4fdbef2b4e
17 changed files with 6258 additions and 5931 deletions

View File

@ -124,3 +124,9 @@ export function getArtist( uri ){
}
}
export function getArtists(){
return {
type: 'MOPIDY_ARTISTS'
}
}

View File

@ -155,6 +155,7 @@ const MopidyMiddleware = (function(){
break;
case 'MOPIDY_PLAYLIST':
store.dispatch({ type: 'MOPIDY_PLAYLIST_LOADED', data: false });
instruct( socket, store, 'playlists.lookup', action.data )
.then( response => {
var playlist = response;
@ -196,6 +197,7 @@ const MopidyMiddleware = (function(){
break;
case 'MOPIDY_ALBUM':
store.dispatch({ type: 'MOPIDY_ALBUM_LOADED', data: false });
instruct( socket, store, 'library.lookup', action.data )
.then( response => {
var album = response[0].album;
@ -238,14 +240,13 @@ const MopidyMiddleware = (function(){
break;
case 'MOPIDY_ARTIST':
store.dispatch({ type: 'MOPIDY_ARTIST_LOADED', data: false });
instruct( socket, store, 'library.lookup', action.data )
.then( response => {
var artist = {
name: 'yeah',
images: [],
albums: [],
tracks: response.slice(0,10)
}
var artist = response[0].artists[0];
artist.images = [];
artist.albums = [];
artist.tracks = response.slice(0,10);
for( var i = 0; i < response.length; i++ ){
var album = response[i].album;
@ -263,6 +264,16 @@ const MopidyMiddleware = (function(){
})
break;
case 'MOPIDY_ARTISTS':
store.dispatch({ type: 'MOPIDY_ARTISTS_LOADED', data: false });
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
.then( response => {
var artists = response;
store.dispatch({ type: 'MOPIDY_ARTISTS_LOADED', data: artists });
})
break;
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);

View File

@ -92,6 +92,11 @@ export default function reducer(mopidy = {}, action){
artist: action.data
});
case 'MOPIDY_ARTISTS_LOADED':
return Object.assign({}, mopidy, {
artists: action.data
});
default:
return mopidy
}