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