Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

reducer.ts 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import {
  3. ADD_PENDING_INVITE_REQUEST,
  4. REMOVE_PENDING_INVITE_REQUESTS,
  5. SET_CALLEE_INFO_VISIBLE,
  6. UPDATE_DIAL_IN_NUMBERS_FAILED,
  7. UPDATE_DIAL_IN_NUMBERS_SUCCESS
  8. } from './actionTypes';
  9. import logger from './logger';
  10. import { IInvitee } from './types';
  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. export interface IInviteState {
  24. calleeInfoVisible?: boolean;
  25. conferenceID?: string | number;
  26. error?: {
  27. status: number;
  28. };
  29. initialCalleeInfo?: Object;
  30. numbers?: string[];
  31. numbersEnabled: boolean;
  32. numbersFetched: boolean;
  33. pendingInviteRequests: Array<{
  34. callback: Function;
  35. invitees: IInvitee[];
  36. }>;
  37. sipUri?: string;
  38. }
  39. ReducerRegistry.register<IInviteState>('features/invite', (state = DEFAULT_STATE, action): IInviteState => {
  40. switch (action.type) {
  41. case ADD_PENDING_INVITE_REQUEST:
  42. return {
  43. ...state,
  44. pendingInviteRequests: [
  45. ...state.pendingInviteRequests,
  46. action.request
  47. ]
  48. };
  49. case REMOVE_PENDING_INVITE_REQUESTS:
  50. return {
  51. ...state,
  52. pendingInviteRequests: []
  53. };
  54. case SET_CALLEE_INFO_VISIBLE:
  55. return {
  56. ...state,
  57. calleeInfoVisible: action.calleeInfoVisible,
  58. initialCalleeInfo: action.initialCalleeInfo
  59. };
  60. case UPDATE_DIAL_IN_NUMBERS_FAILED:
  61. return {
  62. ...state,
  63. error: action.error
  64. };
  65. case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
  66. if (Array.isArray(action.dialInNumbers)) {
  67. return {
  68. ...state,
  69. conferenceID: action.conferenceID,
  70. error: undefined,
  71. numbers: action.dialInNumbers,
  72. sipUri: action.sipUri,
  73. numbersEnabled: true,
  74. numbersFetched: true
  75. };
  76. }
  77. // this is the old format which is deprecated
  78. logger.warn('Using deprecated API for retrieving phone numbers');
  79. const { numbersEnabled } = action.dialInNumbers;
  80. return {
  81. ...state,
  82. conferenceID: action.conferenceID,
  83. error: undefined,
  84. numbers: action.dialInNumbers,
  85. numbersEnabled,
  86. numbersFetched: true
  87. };
  88. }
  89. }
  90. return state;
  91. });