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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. numbersEnabled: true,
  56. numbersFetched: true
  57. };
  58. }
  59. // this is the old format which is deprecated
  60. logger.warn('Using deprecated API for retrieving phone numbers');
  61. const { numbersEnabled } = action.dialInNumbers;
  62. return {
  63. ...state,
  64. conferenceID: action.conferenceID,
  65. numbers: action.dialInNumbers,
  66. numbersEnabled,
  67. numbersFetched: true
  68. };
  69. }
  70. }
  71. return state;
  72. });