Playlist list... not sure if cleanest way to build components
This commit is contained in:
@ -22,6 +22,19 @@ export function disconnect(){
|
||||
}
|
||||
}
|
||||
|
||||
export function instruct( call, value ){
|
||||
return {
|
||||
type: 'MOPIDY_INSTRUCT',
|
||||
call: call,
|
||||
value: value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Playback-oriented actions
|
||||
**/
|
||||
|
||||
export function changeTrack( tlid ){
|
||||
return {
|
||||
type: 'MOPIDY_INSTRUCT',
|
||||
@ -56,14 +69,6 @@ export function removeTracks( tlids ){
|
||||
}
|
||||
}
|
||||
|
||||
export function instruct( call, value ){
|
||||
return {
|
||||
type: 'MOPIDY_INSTRUCT',
|
||||
call: call,
|
||||
value: value
|
||||
}
|
||||
}
|
||||
|
||||
export function play(){
|
||||
return instruct('playback.play');
|
||||
}
|
||||
@ -79,3 +84,14 @@ export function next(){
|
||||
export function previous(){
|
||||
return instruct('playback.previous');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Asset-oriented actions
|
||||
**/
|
||||
|
||||
export function getPlaylists(){
|
||||
return { type: 'MOPIDY_PLAYLISTS' }
|
||||
}
|
||||
|
||||
|
||||
@ -154,6 +154,13 @@ const MopidyMiddleware = (function(){
|
||||
})
|
||||
break;
|
||||
|
||||
case 'MOPIDY_PLAYLISTS':
|
||||
instruct( socket, store, 'playlists.asList' )
|
||||
.then( response => {
|
||||
store.dispatch({ type: 'MOPIDY_PLAYLISTS_LOADED', data: response });
|
||||
})
|
||||
break;
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
return next(action);
|
||||
|
||||
@ -31,6 +31,11 @@ export default function reducer(mopidy = {}, action){
|
||||
}
|
||||
return Object.assign({}, mopidy, { tracks: mopidy.tracks });
|
||||
|
||||
case 'MOPIDY_PLAYLISTS_LOADED':
|
||||
if( !action.data ) return mopidy;
|
||||
return Object.assign({}, mopidy, { playlists: action.data });
|
||||
|
||||
|
||||
/**
|
||||
* Websocket-initiated actions
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user