fix: handle token expiry (#3847)

This commit is contained in:
Erez Rokah
2020-06-03 12:44:03 +03:00
committed by GitHub
parent 43ef28b5dc
commit 285c940562
20 changed files with 282 additions and 17 deletions

View File

@ -1,7 +1,12 @@
import { Map } from 'immutable';
import { USE_OPEN_AUTHORING } from 'Actions/auth';
const LOADING_IGNORE_LIST = ['DEPLOY_PREVIEW'];
const LOADING_IGNORE_LIST = [
'DEPLOY_PREVIEW',
'STATUS_REQUEST',
'STATUS_SUCCESS',
'STATUS_FAILURE',
];
const ignoreWhenLoading = action => LOADING_IGNORE_LIST.some(type => action.type.includes(type));

View File

@ -11,6 +11,7 @@ import medias from './medias';
import mediaLibrary from './mediaLibrary';
import deploys, * as fromDeploys from './deploys';
import globalUI from './globalUI';
import status from './status';
import { Status } from '../constants/publishModes';
import { State, Collection } from '../types/redux';
@ -28,6 +29,7 @@ const reducers = {
mediaLibrary,
deploys,
globalUI,
status,
};
export default reducers;

View File

@ -0,0 +1,33 @@
import { Map, fromJS } from 'immutable';
import { AnyAction } from 'redux';
import { STATUS_REQUEST, STATUS_SUCCESS, STATUS_FAILURE } from '../actions/status';
import { Status } from '../types/redux';
export interface EntriesAction extends AnyAction {
payload: { status: { auth: boolean }; error?: Error };
}
const status = (state = Map(), action: EntriesAction) => {
switch (action.type) {
case STATUS_REQUEST:
return state.set('isFetching', true);
case STATUS_SUCCESS:
return state.withMutations(map => {
map.set('isFetching', false);
map.set('status', fromJS(action.payload.status));
});
case STATUS_FAILURE:
return state.withMutations(map => {
map.set('isFetching', false);
map.set('error', action.payload.error);
});
default:
return state;
}
};
export const selectStatus = (status: Status) => {
return status.get('status')?.toJS() || {};
};
export default status;