You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { equals, set, ReducerRegistry } from '../redux';
  2. import { SET_CALL_OVERLAY_VISIBLE, SET_JWT } from './actionTypes';
  3. /**
  4. * The initial redux state of the feature jwt.
  5. *
  6. * @private
  7. * @type {{
  8. * isGuest: boolean
  9. * }}
  10. */
  11. const _INITIAL_STATE = {
  12. /**
  13. * The indicator which determines whether (the) {@code CallOverlay} is
  14. * visible.
  15. *
  16. * @type {boolean|undefined}
  17. */
  18. callOverlayVisible: undefined,
  19. /**
  20. * The indicator which determines whether the local participant is a guest
  21. * in the conference.
  22. *
  23. * @type {boolean}
  24. */
  25. isGuest: true
  26. };
  27. /**
  28. * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
  29. * redux store.
  30. *
  31. * @param {Object} state - The current redux state.
  32. * @param {Object} action - The redux action to reduce.
  33. * @returns {Object} The next redux state which is the result of reducing the
  34. * specified {@code action}.
  35. */
  36. ReducerRegistry.register(
  37. 'features/base/jwt', (state = _INITIAL_STATE, action) => {
  38. switch (action.type) {
  39. case SET_CALL_OVERLAY_VISIBLE:
  40. return set(state, 'callOverlayVisible', action.callOverlayVisible);
  41. case SET_JWT: {
  42. // eslint-disable-next-line no-unused-vars
  43. const { type, ...payload } = action;
  44. const nextState = {
  45. ..._INITIAL_STATE,
  46. ...payload
  47. };
  48. return equals(state, nextState) ? state : nextState;
  49. }
  50. }
  51. return state;
  52. });