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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @flow
  2. import { MiddlewareRegistry } from '../base/redux';
  3. import {
  4. HIDDEN_PARTICIPANT_JOINED,
  5. HIDDEN_PARTICIPANT_LEFT,
  6. PARTICIPANT_UPDATED
  7. } from './../base/participants';
  8. import {
  9. _TRANSCRIBER_LEFT
  10. } from './actionTypes';
  11. import {
  12. hidePendingTranscribingNotification,
  13. potentialTranscriberJoined,
  14. showStoppedTranscribingNotification,
  15. transcriberJoined,
  16. transcriberLeft
  17. } from './actions';
  18. const TRANSCRIBER_DISPLAY_NAME = 'Transcriber';
  19. /**
  20. * Implements the middleware of the feature transcribing.
  21. *
  22. * @param {Store} store - The redux store.
  23. * @returns {Function}
  24. */
  25. // eslint-disable-next-line no-unused-vars
  26. MiddlewareRegistry.register(store => next => action => {
  27. const {
  28. transcriberJID,
  29. potentialTranscriberJIDs
  30. } = store.getState()['features/transcribing'];
  31. switch (action.type) {
  32. case _TRANSCRIBER_LEFT:
  33. store.dispatch(showStoppedTranscribingNotification());
  34. break;
  35. case HIDDEN_PARTICIPANT_JOINED:
  36. if (action.displayName
  37. && action.displayName === TRANSCRIBER_DISPLAY_NAME) {
  38. store.dispatch(transcriberJoined(action.id));
  39. } else {
  40. store.dispatch(potentialTranscriberJoined(action.id));
  41. }
  42. break;
  43. case HIDDEN_PARTICIPANT_LEFT:
  44. if (action.id === transcriberJID) {
  45. store.dispatch(transcriberLeft(action.id));
  46. }
  47. break;
  48. case PARTICIPANT_UPDATED: {
  49. const { participant } = action;
  50. if (potentialTranscriberJIDs.includes(participant.id)
  51. && participant.name === TRANSCRIBER_DISPLAY_NAME) {
  52. store.dispatch(transcriberJoined(participant.id));
  53. store.dispatch(hidePendingTranscribingNotification());
  54. }
  55. break;
  56. }
  57. }
  58. return next(action);
  59. });