Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct inconsistencies between disableLocalVideoFlip flag and UI #15101

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion react/features/base/tracks/actions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ export function toggleCamera() {
const tracks = state['features/base/tracks'];
const localVideoTrack = getLocalVideoTrack(tracks)?.jitsiTrack;
const currentFacingMode = localVideoTrack.getCameraFacingMode();
const { localFlipX } = state['features/base/settings'];

/**
* FIXME: Ideally, we should be dispatching {@code replaceLocalTrack} here,
Expand All @@ -848,7 +849,7 @@ export function toggleCamera() {
: CAMERA_FACING_MODE.USER;

// Update the flipX value so the environment facing camera is not flipped, before the new track is created.
dispatch(updateSettings({ localFlipX: targetFacingMode === CAMERA_FACING_MODE.USER }));
dispatch(updateSettings({ localFlipX: targetFacingMode === CAMERA_FACING_MODE.USER ? localFlipX : false }));

const newVideoTrack = await createLocalTrack('video', null, null, { facingMode: targetFacingMode });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export interface IProps extends AbstractDialogTabProps, WithTranslation {
*/
disableDeviceChange: boolean;

/**
* Whether the local video can be flipped or not.
*/
disableLocalVideoFlip: boolean | undefined;

/**
* Whether video input dropdown should be enabled or not.
*/
Expand Down Expand Up @@ -203,6 +208,7 @@ class VideoDeviceSelection extends AbstractDialogTab<IProps, IState> {
*/
render() {
const {
disableLocalVideoFlip,
hideAdditionalSettings,
hideVideoInputPreview,
localFlipX,
Expand All @@ -225,13 +231,15 @@ class VideoDeviceSelection extends AbstractDialogTab<IProps, IState> {
</div>
{!hideAdditionalSettings && (
<>
<div className = { classes.checkboxContainer }>
<Checkbox
checked = { localFlipX }
label = { t('videothumbnail.mirrorVideo') }
// eslint-disable-next-line react/jsx-no-bind
onChange = { () => super._onChange({ localFlipX: !localFlipX }) } />
</div>
{!disableLocalVideoFlip && (
<div className = { classes.checkboxContainer }>
<Checkbox
checked = { localFlipX }
label = { t('videothumbnail.mirrorVideo') }
// eslint-disable-next-line react/jsx-no-bind
onChange = { () => super._onChange({ localFlipX: !localFlipX }) } />
</div>
)}
{this._renderFramerateSelect()}
</>
)}
Expand Down
2 changes: 2 additions & 0 deletions react/features/device-selection/functions.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function getVideoDeviceSelectionDialogProps(stateful: IStateful, isDispla
const inputDeviceChangeSupported = JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('input');
const userSelectedCamera = getUserSelectedCameraDeviceId(state);
const { localFlipX } = state['features/base/settings'];
const { disableLocalVideoFlip } = state['features/base/config'];
const hideAdditionalSettings = isPrejoinPageVisible(state) || isDisplayedOnWelcomePage;
const framerate = state['features/screen-share'].captureFrameRate ?? SS_DEFAULT_FRAME_RATE;

Expand All @@ -127,6 +128,7 @@ export function getVideoDeviceSelectionDialogProps(stateful: IStateful, isDispla
desktopShareFramerates: SS_SUPPORTED_FRAMERATES,
disableDeviceChange: !JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(),
disableVideoInputSelect,
disableLocalVideoFlip,
hasVideoPermission: permissions.video,
hideAdditionalSettings,
hideVideoInputPreview: !inputDeviceChangeSupported || disablePreviews,
Expand Down
3 changes: 2 additions & 1 deletion react/features/settings/actions.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,15 @@ export function submitVirtualBackgroundTab(newState: any, isCancel = false) {
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const state = getState();
const track = getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack;
const { localFlipX } = state['features/base/settings'];

if (newState.options?.selectedThumbnail) {
await dispatch(toggleBackgroundEffect(newState.options, track));

if (!isCancel) {
// Set x scale to default value.
dispatch(updateSettings({
localFlipX: true
localFlipX
}));

virtualBackgroundLogger.info(`Virtual background type: '${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export interface IProps {
*/
currentCameraDeviceId: string;

/**
* Whether the local video flip is disabled.
*/
disableLocalVideoFlip: boolean | undefined;

/**
* Whether or not the local video is flipped.
*/
Expand Down Expand Up @@ -146,6 +151,7 @@ const stopPropagation = (e: React.MouseEvent) => {
const VideoSettingsContent = ({
changeFlip,
currentCameraDeviceId,
disableLocalVideoFlip,
localFlipX,
selectBackground,
setVideoInputDevice,
Expand Down Expand Up @@ -310,23 +316,27 @@ const VideoSettingsContent = ({
icon = { IconImage }
onClick = { selectBackground }
text = { t('virtualBackground.title') } /> }
<div
className = { classes.checkboxContainer }
onClick = { stopPropagation }>
<Checkbox
checked = { localFlipX }
label = { t('videothumbnail.mirrorVideo') }
onChange = { _onToggleFlip } />
</div>
{!disableLocalVideoFlip && (
<div
className = { classes.checkboxContainer }
onClick = { stopPropagation }>
<Checkbox
checked = { localFlipX }
label = { t('videothumbnail.mirrorVideo') }
onChange = { _onToggleFlip } />
</div>
)}
</ContextMenuItemGroup>
</ContextMenu>
);
};

const mapStateToProps = (state: IReduxState) => {
const { disableLocalVideoFlip } = state['features/base/config'];
const { localFlipX } = state['features/base/settings'];

return {
disableLocalVideoFlip,
localFlipX: Boolean(localFlipX),
visibleVirtualBackground: checkBlurSupport()
&& checkVirtualBackgroundEnabled(state)
Expand Down