1 import { 2 MEDIA_TYPE, 3 VIDEO_TYPE 4 } from '../media/constants'; 5 import MiddlewareRegistry from '../redux/MiddlewareRegistry'; 6 7 import { 8 TRACK_UPDATED 9 } from './actionTypes'; 10 import { 11 toggleScreensharing 12 } from './actions.native'; 13 14 import './middleware.any'; 15 16 /** 17 * Middleware that captures LIB_DID_DISPOSE and LIB_DID_INIT actions and, 18 * respectively, creates/destroys local media tracks. Also listens to 19 * media-related actions and performs corresponding operations with tracks. 20 * 21 * @param {Store} store - The redux store. 22 * @returns {Function} 23 */ 24 MiddlewareRegistry.register(store => next => action => { 25 switch (action.type) { 26 case TRACK_UPDATED: { 27 const { jitsiTrack, local } = action.track; 28 29 if (local && jitsiTrack.isMuted() 30 && jitsiTrack.type === MEDIA_TYPE.VIDEO && jitsiTrack.videoType === VIDEO_TYPE.DESKTOP) { 31 store.dispatch(toggleScreensharing(false)); 32 } 33 break; 34 } 35 } 36 37 return next(action); 38 });