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.5KB

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