diff --git a/conference.js b/conference.js index bbb2c650adb..43762f78b9d 100644 --- a/conference.js +++ b/conference.js @@ -130,7 +130,7 @@ import { trackAdded, trackRemoved } from './react/features/base/tracks/actions'; -import { setCameraFacingMode } from './react/features/base/tracks/actions.any'; +import { setCameraFacingMode } from './react/features/base/tracks/actions.web'; import { createLocalTracksF, getLocalJitsiAudioTrack, diff --git a/modules/API/API.js b/modules/API/API.js index e53f5ca51a0..610246097c5 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -50,7 +50,7 @@ import { } from '../../react/features/base/participants/functions'; import { updateSettings } from '../../react/features/base/settings/actions'; import { getDisplayName } from '../../react/features/base/settings/functions.web'; -import { setCameraFacingMode } from '../../react/features/base/tracks/actions.any'; +import { setCameraFacingMode } from '../../react/features/base/tracks/actions.web'; import { autoAssignToBreakoutRooms, closeBreakoutRoom, diff --git a/react/features/base/tracks/actions.any.ts b/react/features/base/tracks/actions.any.ts index 6b6c349ff18..a5044ec1cc0 100644 --- a/react/features/base/tracks/actions.any.ts +++ b/react/features/base/tracks/actions.any.ts @@ -38,8 +38,7 @@ import { getLocalTrack, getLocalTracks, getLocalVideoTrack, - getTrackByJitsiTrack, - isToggleCameraEnabled + getTrackByJitsiTrack } from './functions'; import logger from './logger'; import { ITrackOptions } from './types'; @@ -866,37 +865,3 @@ export function toggleCamera() { }; } -/** - * Sets the camera facing mode(environment/user). If facing mode not provided, it will do a toggle. - * - * @param {string | undefined} facingMode - The selected facing mode. - * @returns {void} - */ -export function setCameraFacingMode(facingMode: string | undefined) { - return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => { - const state = getState(); - - if (!isToggleCameraEnabled(state)) { - return; - } - - if (!facingMode) { - dispatch(toggleCamera()); - - return; - } - - const tracks = state['features/base/tracks']; - const localVideoTrack = getLocalVideoTrack(tracks)?.jitsiTrack; - - if (!tracks || !localVideoTrack) { - return; - } - - const currentFacingMode = localVideoTrack.getCameraFacingMode(); - - if (currentFacingMode !== facingMode) { - dispatch(toggleCamera()); - } - }; -} diff --git a/react/features/base/tracks/actions.web.ts b/react/features/base/tracks/actions.web.ts index ffe6915d1be..e57f11e9cfd 100644 --- a/react/features/base/tracks/actions.web.ts +++ b/react/features/base/tracks/actions.web.ts @@ -19,12 +19,15 @@ import { MEDIA_TYPE, VIDEO_TYPE } from '../media/constants'; import { addLocalTrack, - replaceLocalTrack + replaceLocalTrack, + toggleCamera } from './actions.any'; import { createLocalTracksF, getLocalDesktopTrack, - getLocalJitsiAudioTrack + getLocalJitsiAudioTrack, + getLocalVideoTrack, + isToggleCameraEnabled } from './functions'; import { IShareOptions, IToggleScreenSharingOptions } from './types'; @@ -263,3 +266,38 @@ async function _toggleScreenSharing( APP.API.notifyScreenSharingStatusChanged(enable, screensharingDetails); } } + +/** + * Sets the camera facing mode(environment/user). If facing mode not provided, it will do a toggle. + * + * @param {string | undefined} facingMode - The selected facing mode. + * @returns {void} + */ +export function setCameraFacingMode(facingMode: string | undefined) { + return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => { + const state = getState(); + + if (!isToggleCameraEnabled(state)) { + return; + } + + if (!facingMode) { + dispatch(toggleCamera()); + + return; + } + + const tracks = state['features/base/tracks']; + const localVideoTrack = getLocalVideoTrack(tracks)?.jitsiTrack; + + if (!tracks || !localVideoTrack) { + return; + } + + const currentFacingMode = localVideoTrack.getCameraFacingMode(); + + if (currentFacingMode !== facingMode) { + dispatch(toggleCamera()); + } + }; +}