Files
Iris/src/js/services/spotify/middleware.js

34 lines
975 B
JavaScript
Raw Normal View History

2016-10-24 21:26:01 +13:00
var actions = require('./actions.js')
const SpotifyMiddleware = (function(){
/**
* The actual middleware inteceptor
**/
return store => next => action => {
var state = store.getState();
switch(action.type){
2016-10-24 21:26:01 +13:00
// when our mopidy server current track changes
case 'MOPIDY_CURRENTTLTRACK_XX':
// DISABLED AS IT CAUSES ISSUE
2016-10-24 21:26:01 +13:00
// proceed as usual so we don't inhibit default functionality
next(action)
2016-10-24 21:26:01 +13:00
// if the current track is a spotify track
if( action.data.track.uri.substring(0,14) == 'spotify:track:' ){
store.dispatch( actions.getTrack( action.data.track.uri ) )
}
2016-10-19 14:09:34 +13:00
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);
}
}
})();
export default SpotifyMiddleware