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 2.3KB

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