2016-10-16 12:37:37 +13:00
|
|
|
|
|
|
|
|
import actions from './actions'
|
|
|
|
|
|
|
|
|
|
const SpotifyMiddleware = (function(){
|
|
|
|
|
|
2016-10-17 10:39:11 +13:00
|
|
|
/**
|
|
|
|
|
* The actual middleware inteceptor
|
|
|
|
|
**/
|
|
|
|
|
return store => next => action => {
|
2016-10-21 09:56:07 +13:00
|
|
|
return next(action);
|
|
|
|
|
/*
|
2016-10-18 21:57:29 +13:00
|
|
|
var state = store.getState();
|
|
|
|
|
|
|
|
|
|
switch(action.type){
|
2016-10-17 10:39:11 +13:00
|
|
|
|
2016-10-21 09:56:07 +13:00
|
|
|
case 'SPOTIFY_AUTHORIZATION_GRANTEDXXX':
|
|
|
|
|
|
|
|
|
|
// proceed as usual
|
|
|
|
|
next(action)
|
|
|
|
|
|
|
|
|
|
// now we've been granted,
|
|
|
|
|
store.dispatch({ type: 'SPOTIFY_AUTHORIZATION_COMPLETE', data: data })
|
2016-10-19 14:09:34 +13:00
|
|
|
break;
|
|
|
|
|
|
2016-10-16 12:37:37 +13:00
|
|
|
// This action is irrelevant to us, pass it on to the next middleware
|
|
|
|
|
default:
|
|
|
|
|
return next(action);
|
|
|
|
|
}
|
2016-10-21 09:56:07 +13:00
|
|
|
*/
|
2016-10-16 12:37:37 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
export default SpotifyMiddleware
|