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

middleware.js 2.4KB

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