Sharing of configuration and other authorizations

This commit is contained in:
James Barnsley
2018-09-30 20:09:12 +13:00
parent 96359e0b42
commit 127a8322d0
26 changed files with 996 additions and 472 deletions

View File

@ -152,6 +152,13 @@ export function revokeAuthorization(){
}
}
export function importAuthorization(authorization){
return {
type: 'LASTFM_IMPORT_AUTHORIZATION',
authorization: authorization
}
}
/**

View File

@ -1,6 +1,7 @@
var helpers = require('./../../helpers');
var coreActions = require('../core/actions');
var lastfmActions = require('./actions');
const LastfmMiddleware = (function(){
@ -20,6 +21,15 @@ const LastfmMiddleware = (function(){
next(action);
break;
case 'LASTFM_IMPORT_AUTHORIZATION':
// Wait a few moments before we fetch, allowing the import to complete first
// TODO: Use callbacks for better code accuracy
setTimeout(() => {store.dispatch(lastfmActions.getMe())}, 100);
next(action);
break;
default:
return next(action);
}

View File

@ -27,7 +27,14 @@ export default function reducer(lastfm = {}, action){
return Object.assign({}, lastfm, {
authorizing: false,
session: false,
me: false
me: null
});
case 'LASTFM_IMPORT_AUTHORIZATION':
return Object.assign({}, lastfm, {
authorizing: false,
session: action.authorization,
me: null
});
default: