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 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import {
  3. TRANSCRIBER_JOINED,
  4. TRANSCRIBER_LEFT
  5. } from './actionTypes';
  6. /**
  7. * Returns initial state for transcribing feature part of Redux store.
  8. *
  9. * @returns {{
  10. * isTranscribing: boolean,
  11. * transcriberJID: null
  12. * }}
  13. * @private
  14. */
  15. function _getInitialState() {
  16. return {
  17. /**
  18. * Indicates whether there is currently an active transcriber in the
  19. * room.
  20. *
  21. * @type {boolean}
  22. */
  23. isTranscribing: false,
  24. /**
  25. * The JID of the active transcriber.
  26. *
  27. * @type { string }
  28. */
  29. transcriberJID: null
  30. };
  31. }
  32. export interface ITranscribingState {
  33. isTranscribing: boolean;
  34. transcriberJID?: string | null;
  35. }
  36. /**
  37. * Reduces the Redux actions of the feature features/transcribing.
  38. */
  39. ReducerRegistry.register<ITranscribingState>('features/transcribing',
  40. (state = _getInitialState(), action): ITranscribingState => {
  41. switch (action.type) {
  42. case TRANSCRIBER_JOINED:
  43. return {
  44. ...state,
  45. isTranscribing: true,
  46. transcriberJID: action.transcriberJID
  47. };
  48. case TRANSCRIBER_LEFT:
  49. return {
  50. ...state,
  51. isTranscribing: false,
  52. transcriberJID: undefined
  53. };
  54. default:
  55. return state;
  56. }
  57. });