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.

middleware.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* @flow */
  2. import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
  3. import { CONFERENCE_JOINED } from '../base/conference';
  4. import { i18next } from '../base/i18n';
  5. import { MiddlewareRegistry } from '../base/redux';
  6. import { showNotification } from '../notifications';
  7. import { recordingController } from './controller';
  8. import { signalLocalRecordingEngagement } from './actions';
  9. MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
  10. const result = next(action);
  11. switch (action.type) {
  12. case CONFERENCE_JOINED: {
  13. // the Conference object is ready
  14. const { conference } = getState()['features/base/conference'];
  15. recordingController.registerEvents(conference);
  16. break;
  17. }
  18. case APP_WILL_MOUNT:
  19. // realize the delegates on recordingController,
  20. // providing UI reactions.
  21. recordingController.onStateChanged = function(state) {
  22. dispatch(signalLocalRecordingEngagement(state));
  23. };
  24. recordingController.onWarning = function(message) {
  25. dispatch(showNotification({
  26. title: i18next.t('localRecording.localRecording'),
  27. description: message
  28. }, 10000));
  29. };
  30. recordingController.onNotify = function(message) {
  31. dispatch(showNotification({
  32. title: i18next.t('localRecording.localRecording'),
  33. description: message
  34. }, 10000));
  35. };
  36. break;
  37. case APP_WILL_UNMOUNT:
  38. recordingController.onStateChanged = null;
  39. recordingController.onNotify = null;
  40. recordingController.onWarning = null;
  41. break;
  42. }
  43. return result;
  44. });