2017-10-12 19:59:11 +00:00
|
|
|
// @flow
|
|
|
|
|
2018-06-26 22:56:22 +00:00
|
|
|
import { equals, ReducerRegistry } from '../redux';
|
2017-04-21 10:00:50 +00:00
|
|
|
|
2018-06-26 22:56:22 +00:00
|
|
|
import { SET_JWT } from './actionTypes';
|
2017-04-21 10:00:50 +00:00
|
|
|
|
|
|
|
/**
|
2018-02-14 18:28:22 +00:00
|
|
|
* The default/initial redux state of the feature jwt.
|
2017-04-21 10:00:50 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {{
|
|
|
|
* isGuest: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
2018-02-14 18:28:22 +00:00
|
|
|
const DEFAULT_STATE = {
|
2017-04-21 10:00:50 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether the local participant is a guest
|
|
|
|
* in the conference.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
isGuest: true
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces redux actions which affect the JSON Web Token (JWT) stored in the
|
|
|
|
* redux store.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The current redux state.
|
|
|
|
* @param {Object} action - The redux action to reduce.
|
|
|
|
* @returns {Object} The next redux state which is the result of reducing the
|
|
|
|
* specified {@code action}.
|
|
|
|
*/
|
2017-10-05 22:54:13 +00:00
|
|
|
ReducerRegistry.register(
|
2017-10-12 19:59:11 +00:00
|
|
|
'features/base/jwt',
|
2018-02-14 18:28:22 +00:00
|
|
|
(state = DEFAULT_STATE, action) => {
|
2017-10-12 19:59:11 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SET_JWT: {
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
const { type, ...payload } = action;
|
|
|
|
const nextState = {
|
2018-02-14 18:28:22 +00:00
|
|
|
...DEFAULT_STATE,
|
2017-10-12 19:59:11 +00:00
|
|
|
...payload
|
|
|
|
};
|
|
|
|
|
|
|
|
return equals(state, nextState) ? state : nextState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|