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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // eslint-disable-next-line lines-around-comment
  7. // @ts-ignore
  8. import StopRecordingDialog from '../../recording/components/Recording/web/StopRecordingDialog';
  9. import { openDialog } from '../dialog/actions';
  10. import MiddlewareRegistry from '../redux/MiddlewareRegistry';
  11. import { SET_VIDEO_MUTED } from './actionTypes';
  12. import './subscriber';
  13. /**
  14. * Implements the entry point of the middleware of the feature base/media.
  15. *
  16. * @param {IStore} store - The redux store.
  17. * @returns {Function}
  18. */
  19. MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: any) => {
  20. const { dispatch } = store;
  21. switch (action.type) {
  22. case SET_VIDEO_MUTED: {
  23. if (LocalRecordingManager.isRecordingLocally() && LocalRecordingManager.selfRecording.on) {
  24. if (action.muted && LocalRecordingManager.selfRecording.withVideo) {
  25. dispatch(openDialog(StopRecordingDialog, { localRecordingVideoStop: true }));
  26. return;
  27. } else if (!action.muted && !LocalRecordingManager.selfRecording.withVideo) {
  28. dispatch(showNotification({
  29. titleKey: 'recording.localRecordingNoVideo',
  30. descriptionKey: 'recording.localRecordingVideoWarning',
  31. uid: 'recording.localRecordingNoVideo'
  32. }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
  33. }
  34. }
  35. }
  36. }
  37. return next(action);
  38. });