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

middleware.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* @flow */
  2. import { createShortcutEvent, sendAnalytics } from '../analytics';
  3. import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
  4. import { CONFERENCE_JOINED } from '../base/conference';
  5. import { toggleDialog } from '../base/dialog';
  6. import { i18next } from '../base/i18n';
  7. import { MiddlewareRegistry } from '../base/redux';
  8. import { showNotification } from '../notifications';
  9. import { localRecordingEngaged, localRecordingUnengaged } from './actions';
  10. import { LocalRecordingInfoDialog } from './components';
  11. import { recordingController } from './controller';
  12. declare var APP: Object;
  13. declare var config: Object;
  14. const isFeatureEnabled = config.localRecording
  15. && config.localRecording.enabled === true;
  16. isFeatureEnabled
  17. && MiddlewareRegistry.register(({ getState, dispatch }) => next => action => {
  18. const result = next(action);
  19. switch (action.type) {
  20. case CONFERENCE_JOINED: {
  21. const { conference } = getState()['features/base/conference'];
  22. recordingController.registerEvents(conference);
  23. break;
  24. }
  25. case APP_WILL_MOUNT:
  26. // realize the delegates on recordingController, allowing the UI to
  27. // react to state changes in recordingController.
  28. recordingController.onStateChanged = isEngaged => {
  29. if (isEngaged) {
  30. const nowTime = new Date();
  31. dispatch(localRecordingEngaged(nowTime));
  32. } else {
  33. dispatch(localRecordingUnengaged());
  34. }
  35. };
  36. recordingController.onWarning = (messageKey, messageParams) => {
  37. dispatch(showNotification({
  38. title: i18next.t('localRecording.localRecording'),
  39. description: i18next.t(messageKey, messageParams)
  40. }, 10000));
  41. };
  42. recordingController.onNotify = (messageKey, messageParams) => {
  43. dispatch(showNotification({
  44. title: i18next.t('localRecording.localRecording'),
  45. description: i18next.t(messageKey, messageParams)
  46. }, 10000));
  47. };
  48. APP.keyboardshortcut.registerShortcut('L', null, () => {
  49. sendAnalytics(createShortcutEvent('local.recording'));
  50. dispatch(toggleDialog(LocalRecordingInfoDialog));
  51. }, 'keyboardShortcuts.localRecording');
  52. break;
  53. case APP_WILL_UNMOUNT:
  54. recordingController.onStateChanged = null;
  55. recordingController.onNotify = null;
  56. recordingController.onWarning = null;
  57. break;
  58. }
  59. // @todo: detect change in features/base/settings micDeviceID
  60. // @todo: SET_AUDIO_MUTED, when audio is muted
  61. return result;
  62. });