fix: handle token expiry (#3847)
This commit is contained in:
@ -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));
|
||||
|
||||
|
@ -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;
|
||||
|
33
packages/netlify-cms-core/src/reducers/status.ts
Normal file
33
packages/netlify-cms-core/src/reducers/status.ts
Normal 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;
|
Reference in New Issue
Block a user