Pusher username setting fully working
This commit is contained in:
@ -6,7 +6,7 @@ const localstorageMiddleware = (function(){
|
||||
**/
|
||||
return store => next => action => {
|
||||
|
||||
console.log(action, store.getState())
|
||||
console.log(action);//, store.getState())
|
||||
|
||||
// proceed as normal first
|
||||
// this way, any reducers and middleware do their thing BEFORE we store our new state
|
||||
@ -15,10 +15,14 @@ const localstorageMiddleware = (function(){
|
||||
switch( action.type ){
|
||||
|
||||
case 'PUSHER_SET_CONFIG':
|
||||
var pusher = {
|
||||
username: action.config.username,
|
||||
port: action.config.port
|
||||
};
|
||||
var pusher = JSON.parse( localStorage.getItem('pusher') );
|
||||
if( !pusher ) pusher = {};
|
||||
Object.assign(
|
||||
pusher,{
|
||||
username: action.config.username,
|
||||
port: action.config.port
|
||||
}
|
||||
);
|
||||
localStorage.setItem('pusher', JSON.stringify(pusher));
|
||||
break;
|
||||
|
||||
@ -27,12 +31,20 @@ const localstorageMiddleware = (function(){
|
||||
if( !pusher ) pusher = {};
|
||||
Object.assign(
|
||||
pusher,{
|
||||
username: action.connection.username,
|
||||
connectionid: action.connection.connectionid
|
||||
}
|
||||
);
|
||||
localStorage.setItem('pusher', JSON.stringify(pusher));
|
||||
break;
|
||||
|
||||
case 'PUSHER_CHANGE_USERNAME':
|
||||
var pusher = JSON.parse( localStorage.getItem('pusher') );
|
||||
if( !pusher ) pusher = {};
|
||||
Object.assign( pusher,{ username: action.data.connection.username });
|
||||
localStorage.setItem('pusher', JSON.stringify(pusher));
|
||||
break;
|
||||
|
||||
case 'MOPIDY_SET_CONFIG':
|
||||
var mopidy = {
|
||||
host: action.config.host,
|
||||
@ -63,6 +75,20 @@ const localstorageMiddleware = (function(){
|
||||
localStorage.setItem('spotify', JSON.stringify(spotify));
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_AUTHORIZATION_REVOKED':
|
||||
var spotify = JSON.parse( localStorage.getItem('spotify') );
|
||||
if( !spotify ) spotify = {};
|
||||
Object.assign(
|
||||
spotify,{
|
||||
authorized: false,
|
||||
access_token: false,
|
||||
refresh_token: false,
|
||||
token_expiry: false
|
||||
}
|
||||
);
|
||||
localStorage.setItem('spotify', JSON.stringify(spotify));
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_TOKEN_REFRESHED':
|
||||
var spotify = JSON.parse( localStorage.getItem('spotify') );
|
||||
if( !spotify ) spotify = {};
|
||||
@ -74,6 +100,17 @@ const localstorageMiddleware = (function(){
|
||||
);
|
||||
localStorage.setItem('spotify', JSON.stringify(spotify));
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_ME_LOADED':
|
||||
var spotify = JSON.parse( localStorage.getItem('spotify') );
|
||||
if( !spotify ) spotify = {};
|
||||
Object.assign(
|
||||
spotify,{
|
||||
me: action.data
|
||||
}
|
||||
);
|
||||
localStorage.setItem('spotify', JSON.stringify(spotify));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user