From 00e6d01abfd21f4bc1fb4f9cfe669ad1811c5ee4 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Fri, 8 Sep 2017 14:40:43 +1200 Subject: [PATCH] Asserting that imported authorizations are added to localStorage, addresses #117 --- src/js/services/localstorage/middleware.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/services/localstorage/middleware.js b/src/js/services/localstorage/middleware.js index c4569e94..6d5dad18 100755 --- a/src/js/services/localstorage/middleware.js +++ b/src/js/services/localstorage/middleware.js @@ -81,23 +81,28 @@ const localstorageMiddleware = (function(){ localStorage.setItem('spotify', JSON.stringify(spotify)); break; + case 'SPOTIFY_IMPORT_AUTHORIZATION': case 'SPOTIFY_AUTHORIZATION_GRANTED': + if (action.authorization !== undefined){ + var authorization = action.authorization; + } else if (action.data){ + var authorization = action.data; + } var spotify = JSON.parse( localStorage.getItem('spotify') ); spotify = Object.assign( {}, (spotify ? spotify : {}), { - authorization: action.data, - access_token: action.data.access_token, - refresh_token: action.data.refresh_token, - token_expiry: action.data.token_expiry + authorization: authorization, + access_token: authorization.access_token, + refresh_token: authorization.refresh_token, + token_expiry: authorization.token_expiry } ); localStorage.setItem('spotify', JSON.stringify(spotify)); break; case 'SPOTIFY_AUTHORIZATION_REVOKED': - console.log('local',action) var spotify = JSON.parse( localStorage.getItem('spotify') ); spotify = Object.assign( {}, @@ -109,7 +114,6 @@ const localstorageMiddleware = (function(){ token_expiry: false } ); - console.log(spotify) localStorage.setItem('spotify', JSON.stringify(spotify)); break;