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

middleware.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 { localRecordingEngaged, localRecordingUnengaged } from './actions';
  8. import { recordingController } from './controller';
  9. MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
  10. const result = next(action);
  11. switch (action.type) {
  12. case CONFERENCE_JOINED: {
  13. const { conference } = getState()['features/base/conference'];
  14. recordingController.registerEvents(conference);
  15. break;
  16. }
  17. case APP_WILL_MOUNT:
  18. // realize the delegates on recordingController, allowing the UI to
  19. // react to state changes in recordingController.
  20. recordingController.onStateChanged = function(isEngaged) {
  21. if (isEngaged) {
  22. dispatch(localRecordingEngaged());
  23. } else {
  24. dispatch(localRecordingUnengaged());
  25. }
  26. };
  27. recordingController.onWarning = function(message) {
  28. dispatch(showNotification({
  29. title: i18next.t('localRecording.localRecording'),
  30. description: message
  31. }, 10000));
  32. };
  33. recordingController.onNotify = function(message) {
  34. dispatch(showNotification({
  35. title: i18next.t('localRecording.localRecording'),
  36. description: message
  37. }, 10000));
  38. };
  39. break;
  40. case APP_WILL_UNMOUNT:
  41. recordingController.onStateChanged = null;
  42. recordingController.onNotify = null;
  43. recordingController.onWarning = null;
  44. break;
  45. }
  46. // @todo: detect change in features/base/settings micDeviceID
  47. // @todo: SET_AUDIO_MUTED, when audio is muted
  48. return result;
  49. });