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.web.ts 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import './middleware.any.js';
  2. import { IStore } from '../../app/types';
  3. import { showNotification } from '../../notifications/actions';
  4. import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
  5. import LocalRecordingManager from '../../recording/components/Recording/LocalRecordingManager.web';
  6. import StopRecordingDialog from '../../recording/components/Recording/web/StopRecordingDialog';
  7. import { openDialog } from '../dialog/actions';
  8. import MiddlewareRegistry from '../redux/MiddlewareRegistry';
  9. import { SET_VIDEO_MUTED } from './actionTypes';
  10. import './subscriber';
  11. /**
  12. * Implements the entry point of the middleware of the feature base/media.
  13. *
  14. * @param {IStore} store - The redux store.
  15. * @returns {Function}
  16. */
  17. MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: any) => {
  18. const { dispatch } = store;
  19. switch (action.type) {
  20. case SET_VIDEO_MUTED: {
  21. if (LocalRecordingManager.isRecordingLocally() && LocalRecordingManager.selfRecording.on) {
  22. if (action.muted && LocalRecordingManager.selfRecording.withVideo) {
  23. dispatch(openDialog(StopRecordingDialog, { localRecordingVideoStop: true }));
  24. return;
  25. } else if (!action.muted && !LocalRecordingManager.selfRecording.withVideo) {
  26. dispatch(showNotification({
  27. titleKey: 'recording.localRecordingNoVideo',
  28. descriptionKey: 'recording.localRecordingVideoWarning',
  29. uid: 'recording.localRecordingNoVideo'
  30. }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
  31. }
  32. }
  33. }
  34. }
  35. return next(action);
  36. });