Pusher username management; Spotify vs mopidy middleware glitching

This commit is contained in:
James Barnsley
2016-10-28 09:14:29 +13:00
parent 7be39dc4d4
commit 696e385b7e
10 changed files with 199 additions and 32 deletions

View File

@ -6,7 +6,7 @@ const localstorageMiddleware = (function(){
**/
return store => next => action => {
console.log(action)
console.log(action, store.getState())
// proceed as normal first
// this way, any reducers and middleware do their thing BEFORE we store our new state
@ -14,6 +14,25 @@ const localstorageMiddleware = (function(){
switch( action.type ){
case 'PUSHER_SET_CONFIG':
var pusher = {
username: action.config.username,
port: action.config.port
};
localStorage.setItem('pusher', JSON.stringify(pusher));
break;
case 'PUSHER_CONNECTED':
var pusher = JSON.parse( localStorage.getItem('pusher') );
if( !pusher ) pusher = {};
Object.assign(
pusher,{
connectionid: action.connection.connectionid
}
);
localStorage.setItem('pusher', JSON.stringify(pusher));
break;
case 'MOPIDY_SET_CONFIG':
var mopidy = {
host: action.config.host,