您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 3.0KB

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