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

reducer.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. ADD_PENDING_INVITE_REQUEST,
  5. REMOVE_PENDING_INVITE_REQUESTS,
  6. SET_CALLEE_INFO_VISIBLE,
  7. UPDATE_DIAL_IN_NUMBERS_FAILED,
  8. UPDATE_DIAL_IN_NUMBERS_SUCCESS
  9. } from './actionTypes';
  10. import logger from './logger';
  11. const DEFAULT_STATE = {
  12. /**
  13. * The indicator which determines whether (the) {@code CalleeInfo} is
  14. * visible.
  15. *
  16. * @type {boolean|undefined}
  17. */
  18. calleeInfoVisible: false,
  19. numbersEnabled: true,
  20. numbersFetched: false,
  21. pendingInviteRequests: []
  22. };
  23. ReducerRegistry.register('features/invite', (state = DEFAULT_STATE, action) => {
  24. switch (action.type) {
  25. case ADD_PENDING_INVITE_REQUEST:
  26. return {
  27. ...state,
  28. pendingInviteRequests: [
  29. ...state.pendingInviteRequests,
  30. action.request
  31. ]
  32. };
  33. case REMOVE_PENDING_INVITE_REQUESTS:
  34. return {
  35. ...state,
  36. pendingInviteRequests: []
  37. };
  38. case SET_CALLEE_INFO_VISIBLE:
  39. return {
  40. ...state,
  41. calleeInfoVisible: action.calleeInfoVisible,
  42. initialCalleeInfo: action.initialCalleeInfo
  43. };
  44. case UPDATE_DIAL_IN_NUMBERS_FAILED:
  45. return {
  46. ...state,
  47. error: action.error
  48. };
  49. case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
  50. if (Array.isArray(action.dialInNumbers)) {
  51. return {
  52. ...state,
  53. conferenceID: action.conferenceID,
  54. numbers: action.dialInNumbers,
  55. sipUri: action.sipUri,
  56. numbersEnabled: true,
  57. numbersFetched: true
  58. };
  59. }
  60. // this is the old format which is deprecated
  61. logger.warn('Using deprecated API for retrieving phone numbers');
  62. const { numbersEnabled } = action.dialInNumbers;
  63. return {
  64. ...state,
  65. conferenceID: action.conferenceID,
  66. numbers: action.dialInNumbers,
  67. numbersEnabled,
  68. numbersFetched: true
  69. };
  70. }
  71. }
  72. return state;
  73. });