Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
horymury committed Aug 16, 2023
1 parent 8198ef1 commit 35ea879
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 35 deletions.
35 changes: 0 additions & 35 deletions react/features/base/tracks/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { AnyAction } from 'redux';
import { IStore } from '../../app/types';
import { hideNotification } from '../../notifications/actions';
import { isPrejoinPageVisible } from '../../prejoin/functions';
import { CONFERENCE_JOINED } from '../conference/actionTypes';
import { IJitsiConference } from '../conference/reducer';
import { getAvailableDevices } from '../devices/actions.web';
import { JitsiConferenceEvents } from '../lib-jitsi-meet';
import { setScreenshareMuted } from '../media/actions';
import {
MEDIA_TYPE,
Expand All @@ -23,13 +20,10 @@ import {
TRACK_UPDATED
} from './actionTypes';
import {
openAllowToggleCameraDialog,
setCameraFacingMode,
showNoDataFromSourceVideoError,
toggleScreensharing,
trackNoDataFromSourceNotificationInfoChanged
} from './actions.web';
import { CAMERA_FACING_MODE_MESSAGE } from './constants';
import {
getTrackByJitsiTrack
} from './functions.web';
Expand Down Expand Up @@ -127,40 +121,11 @@ MiddlewareRegistry.register(store => next => action => {
return result;
}

case CONFERENCE_JOINED: {
_addSetCameraFacingModeListener(action.conference);
break;
}
}

return next(action);
});

/**
* Registers listener for {@link JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED} that
* will perform various chat related activities.
*
* @param {IJitsiConference} conference - The conference.
* @returns {void}
*/
function _addSetCameraFacingModeListener(conference: IJitsiConference) {
conference.on(
JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
(...args: any) => {
if (args && args.length >= 2) {
const [ sender, eventData ] = args;

if (eventData.name === CAMERA_FACING_MODE_MESSAGE) {
APP.store.dispatch(openAllowToggleCameraDialog(
/* onAllow */ () => APP.store.dispatch(setCameraFacingMode(eventData.facingMode)),
/* initiatorId */ sender._id
));
}
}
}
);
}

/**
* Handles no data from source errors.
*
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions react/features/conference/middleware.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './middleware.any';
45 changes: 45 additions & 0 deletions react/features/conference/middleware.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
import { IJitsiConference } from '../base/conference/reducer';
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { openAllowToggleCameraDialog, setCameraFacingMode } from '../base/tracks/actions.web';
import { CAMERA_FACING_MODE_MESSAGE } from '../base/tracks/constants';

import './middleware.any';

MiddlewareRegistry.register(_store => next => action => {
switch (action.type) {
case CONFERENCE_JOINED: {
_addSetCameraFacingModeListener(action.conference);
break;
}
}

return next(action);
});

/**
* Registers listener for {@link JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED} that
* will perform various chat related activities.
*
* @param {IJitsiConference} conference - The conference.
* @returns {void}
*/
function _addSetCameraFacingModeListener(conference: IJitsiConference) {
conference.on(
JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
(...args: any) => {
if (args && args.length >= 2) {
const [ sender, eventData ] = args;

if (eventData.name === CAMERA_FACING_MODE_MESSAGE) {
APP.store.dispatch(openAllowToggleCameraDialog(
/* onAllow */ () => APP.store.dispatch(setCameraFacingMode(eventData.facingMode)),
/* initiatorId */ sender._id
));
}
}
}
);
}

0 comments on commit 35ea879

Please sign in to comment.