jiti-meet/react/features/authentication/reducer.js

42 lines
1011 B
JavaScript
Raw Normal View History

2017-09-18 07:09:43 +00:00
/* @flow */
import { assign, ReducerRegistry } from '../base/redux';
2017-09-08 13:36:42 +00:00
import {
CANCEL_LOGIN,
STOP_WAIT_FOR_OWNER,
2017-09-18 07:09:43 +00:00
UPGRADE_ROLE_FINISHED,
UPGRADE_ROLE_STARTED,
2017-09-08 13:36:42 +00:00
WAIT_FOR_OWNER
} from './actionTypes';
2017-09-18 07:09:43 +00:00
ReducerRegistry.register('features/authentication', (state = {}, action) => {
2017-09-08 13:36:42 +00:00
switch (action.type) {
2017-09-18 07:09:43 +00:00
case CANCEL_LOGIN:
2017-09-08 13:36:42 +00:00
return assign(state, {
upgradeRoleError: undefined,
2017-09-18 07:09:43 +00:00
upgradeRoleInProgress: undefined
2017-09-08 13:36:42 +00:00
});
2017-09-18 07:09:43 +00:00
case STOP_WAIT_FOR_OWNER:
2017-09-08 13:36:42 +00:00
return assign(state, {
upgradeRoleError: undefined,
2017-09-18 07:09:43 +00:00
waitForOwnerTimeoutID: undefined
2017-09-08 13:36:42 +00:00
});
2017-09-18 07:09:43 +00:00
case UPGRADE_ROLE_FINISHED:
case UPGRADE_ROLE_STARTED:
2017-09-08 13:36:42 +00:00
return assign(state, {
upgradeRoleError: action.error,
2017-09-18 07:09:43 +00:00
upgradeRoleInProgress: action.thenableWithCancel
2017-09-08 13:36:42 +00:00
});
2017-09-18 07:09:43 +00:00
case WAIT_FOR_OWNER:
2017-09-08 13:36:42 +00:00
return assign(state, {
2017-09-18 07:09:43 +00:00
waitForOwnerTimeoutID: action.waitForOwnerTimeoutID
2017-09-08 13:36:42 +00:00
});
}
return state;
});