您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 1.2KB

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