Skip to content

Commit

Permalink
Add permission dlg for toggle camera
Browse files Browse the repository at this point in the history
  • Loading branch information
horymury committed Jul 26, 2023
1 parent bdf809b commit bce8c56
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lang/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@
"addMeetingNote": "Add a note about this meeting",
"addOptionalNote": "Add a note (optional):",
"allow": "Allow",
"allowToggleCameraDialog": "Do you allow {{initiatorName}} to toggle your camera facing mode?",
"allowToggleCameraTitle": "Allow toggle camera?",
"alreadySharedVideoMsg": "Another participant is already sharing a video. This conference allows only one shared video at a time.",
"alreadySharedVideoTitle": "Only one shared video is allowed at a time",
"applicationWindow": "Application window",
Expand Down
16 changes: 16 additions & 0 deletions react/features/base/tracks/actions.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { toggleScreenshotCaptureSummary } from '../../screenshot-capture/actions
import { isScreenshotCaptureEnabled } from '../../screenshot-capture/functions';
import { AudioMixerEffect } from '../../stream-effects/audio-mixer/AudioMixerEffect';
import { getCurrentConference } from '../conference/functions';
import { openDialog } from '../dialog/actions';
import { JitsiTrackErrors, JitsiTrackEvents } from '../lib-jitsi-meet';
import { setScreenshareMuted } from '../media/actions';
import { MEDIA_TYPE, VIDEO_TYPE } from '../media/constants';
Expand All @@ -22,6 +23,7 @@ import {
replaceLocalTrack,
toggleCamera
} from './actions.any';
import AllowToggleCameraDialog from './components/web/AllowToggleCameraDialog';
import {
createLocalTracksF,
getLocalDesktopTrack,
Expand Down Expand Up @@ -301,3 +303,17 @@ export function setCameraFacingMode(facingMode: string | undefined) {
}
};
}

/**
* Signals to open the permission dialog for toggling camera remotely.
*
* @param {Function} onAllow - Callback to be executed if permission to toggle camera was granted.
* @param {string} initiatorId - The participant id of the requester.
* @returns {Object} - The open dialog action.
*/
export function openAllowToggleCameraDialog(onAllow: Function, initiatorId: string) {
return openDialog(AllowToggleCameraDialog, {
onAllow,
initiatorId
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { WithTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import { IReduxState } from '../../../../app/types';
import { translate } from '../../../i18n/functions';
import { getParticipantDisplayName } from '../../../participants/functions';
import Dialog from '../../../ui/components/web/Dialog';


interface IProps extends WithTranslation {

/**
* The participant id of the toggle camera requester.
*/
initiatorId: string;

/**
* Function to be invoked after permission to toggle camera granted.
*/
onAllow: () => void;
}

/**
* Dialog to allow toggling camera remotely.
*
* @returns {JSX.Element} - The allow toggle camera dialog.
*/
const AllowToggleCameraDialog = ({ onAllow, t, initiatorId }: IProps): JSX.Element => {
const initiatorName = useSelector((state: IReduxState) => getParticipantDisplayName(state, initiatorId));

return (
<Dialog
ok = {{ translationKey: 'dialog.allow' }}
onSubmit = { onAllow }
titleKey = 'dialog.allowToggleCameraTitle'>
<div>
{ t('dialog.allowToggleCameraDialog', { initiatorName }) }
</div>
</Dialog>
);
};

export default translate(AllowToggleCameraDialog);
8 changes: 6 additions & 2 deletions react/features/base/tracks/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
TRACK_UPDATED
} from './actionTypes';
import {
openAllowToggleCameraDialog,
setCameraFacingMode,
showNoDataFromSourceVideoError,
toggleScreensharing,
Expand Down Expand Up @@ -147,10 +148,13 @@ function _addSetCameraFacingModeListener(conference: IJitsiConference) {
JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
(...args: any) => {
if (args && args.length >= 2) {
const [ , eventData ] = args;
const [ sender, eventData ] = args;

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

0 comments on commit bce8c56

Please sign in to comment.