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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. pendingInviteRequests: []
  21. };
  22. ReducerRegistry.register('features/invite', (state = DEFAULT_STATE, action) => {
  23. switch (action.type) {
  24. case ADD_PENDING_INVITE_REQUEST:
  25. return {
  26. ...state,
  27. pendingInviteRequests: [
  28. ...state.pendingInviteRequests,
  29. action.request
  30. ]
  31. };
  32. case REMOVE_PENDING_INVITE_REQUESTS:
  33. return {
  34. ...state,
  35. pendingInviteRequests: []
  36. };
  37. case SET_CALLEE_INFO_VISIBLE:
  38. return {
  39. ...state,
  40. calleeInfoVisible: action.calleeInfoVisible,
  41. initialCalleeInfo: action.initialCalleeInfo
  42. };
  43. case UPDATE_DIAL_IN_NUMBERS_FAILED:
  44. return {
  45. ...state,
  46. error: action.error
  47. };
  48. case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
  49. if (Array.isArray(action.dialInNumbers)) {
  50. return {
  51. ...state,
  52. conferenceID: action.conferenceID,
  53. numbers: action.dialInNumbers,
  54. numbersEnabled: true
  55. };
  56. }
  57. // this is the old format which is deprecated
  58. logger.warn('Using deprecated API for retrieving phone numbers');
  59. const { numbersEnabled } = action.dialInNumbers;
  60. return {
  61. ...state,
  62. conferenceID: action.conferenceID,
  63. numbers: action.dialInNumbers,
  64. numbersEnabled
  65. };
  66. }
  67. }
  68. return state;
  69. });