Fully operational mopidy middleware; Spotify middleware next

This commit is contained in:
James Barnsley
2016-10-16 12:37:37 +13:00
parent ec7d6ae895
commit 9fddcc9948
20 changed files with 335 additions and 386 deletions

View File

@ -0,0 +1,30 @@
/**
* Actions and Action Creators
**/
export function authorize(){
return {
type: 'SPOTIFY_AUTHORIZING'
}
}
export function connect(){
return {
type: 'SPOTIFY_CONNECTING'
}
}
export function disconnect(){
return {
type: 'SPOTIFY_DISCONNECT'
}
}
export function loadAlbum( uri ){
return {
type: 'SPOTIFY_LOAD_ALBUM',
uri: uri
}
}

View File

@ -0,0 +1,28 @@
import actions from './actions'
const SpotifyMiddleware = (function(){
return store => next => action => {
switch(action.type) {
case 'SPOTIFY_CONNECT':
console.log('Spotify wants to connect')
break;
case 'SPOTIFY_DISCONNECT':
console.log('Spotify wants to DISconnect')
break;
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);
}
}
})();
export default SpotifyMiddleware

View File

@ -0,0 +1,23 @@
export default function reducer(spotify = {}, action){
switch (action.type) {
case 'SPOTIFY_CONNECTING':
return Object.assign({}, spotify, { connected: false, connecting: true });
case 'SPOTIFY_AUTHORIZING':
return Object.assign({}, spotify, { authorizing: true });
case 'SPOTIFY_CONNECTED':
return Object.assign({}, spotify, { connected: true, connecting: false });
case 'SPOTIFY_DISCONNECTED':
return Object.assign({}, spotify, { connected: false, connecting: false });
default:
return spotify
}
}