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

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