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.ts 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import {
  3. SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
  4. _POTENTIAL_TRANSCRIBER_JOINED,
  5. _TRANSCRIBER_JOINED,
  6. _TRANSCRIBER_LEFT
  7. } from './actionTypes';
  8. /**
  9. * Returns initial state for transcribing feature part of Redux store.
  10. *
  11. * @returns {{
  12. * isTranscribing: boolean,
  13. * isDialing: boolean,
  14. * transcriberJID: null,
  15. * potentialTranscriberJIDs: Array
  16. * }}
  17. * @private
  18. */
  19. function _getInitialState() {
  20. return {
  21. /**
  22. * Indicates whether there is currently an active transcriber in the
  23. * room.
  24. *
  25. * @type {boolean}
  26. */
  27. isTranscribing: false,
  28. /**
  29. * Indicates whether the transcriber has been dialed into the room and
  30. * we're currently awaiting successful joining or failure of joining.
  31. *
  32. * @type {boolean}
  33. */
  34. isDialing: false,
  35. /**
  36. * Indicates whether the transcribing feature is in the process of
  37. * terminating; the transcriber has been told to leave.
  38. */
  39. isTerminating: false,
  40. /**
  41. * The JID of the active transcriber.
  42. *
  43. * @type { string }
  44. */
  45. transcriberJID: null,
  46. /**
  47. * A list containing potential JID's of transcriber participants.
  48. *
  49. * @type { Array }
  50. */
  51. potentialTranscriberJIDs: []
  52. };
  53. }
  54. export interface ITranscribingState {
  55. isDialing: boolean;
  56. isTerminating: boolean;
  57. isTranscribing: boolean;
  58. pendingNotificationUid?: string;
  59. potentialTranscriberJIDs: string[];
  60. transcriberJID?: string | null;
  61. }
  62. /**
  63. * Reduces the Redux actions of the feature features/transcribing.
  64. */
  65. ReducerRegistry.register<ITranscribingState>('features/transcribing',
  66. (state = _getInitialState(), action): ITranscribingState => {
  67. switch (action.type) {
  68. case _TRANSCRIBER_JOINED:
  69. return {
  70. ...state,
  71. isTranscribing: true,
  72. isDialing: false,
  73. transcriberJID: action.transcriberJID
  74. };
  75. case _TRANSCRIBER_LEFT:
  76. return {
  77. ...state,
  78. isTerminating: false,
  79. isTranscribing: false,
  80. transcriberJID: undefined,
  81. potentialTranscriberJIDs: []
  82. };
  83. case _POTENTIAL_TRANSCRIBER_JOINED:
  84. return {
  85. ...state,
  86. potentialTranscriberJIDs:
  87. [ action.transcriberJID ]
  88. .concat(state.potentialTranscriberJIDs)
  89. };
  90. case SET_PENDING_TRANSCRIBING_NOTIFICATION_UID:
  91. return {
  92. ...state,
  93. pendingNotificationUid: action.uid
  94. };
  95. default:
  96. return state;
  97. }
  98. });