Skip to content

fix(uPDP): respect call type camera configuration #1883

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions packages/react-sdk/src/hooks/usePersistedDevicePreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ export const usePersistedDevicePreferences = (
'idle' | 'applying' | 'applied'
>('idle');

// when the camera is disabled on call type level, we should discard
// any stored camera preferences.
const cameraDevices = settings?.video?.enabled ? cameraState.devices : false;
useEffect(
function apply() {
if (
callingState === CallingState.LEFT ||
!microphoneState.devices.length ||
!cameraState.devices.length ||
!speakerState.devices ||
microphoneState.devices.length === 0 ||
(Array.isArray(cameraDevices) && cameraDevices.length === 0) ||
speakerState.devices.length === 0 ||
!settings ||
applyingState !== 'idle'
) {
Expand All @@ -91,7 +94,7 @@ export const usePersistedDevicePreferences = (
? applyLocalDevicePreference(
manager,
[preference].flat(),
state.devices,
deviceKey === 'camera' ? cameraDevices || [] : state.devices,
enabledInCallType,
)
: applyMutedState(manager, defaultMuted, enabledInCallType);
Expand All @@ -111,7 +114,7 @@ export const usePersistedDevicePreferences = (
applyingState,
callingState,
cameraState,
cameraState.devices,
cameraDevices,
key,
microphoneState,
microphoneState.devices,
Expand All @@ -130,7 +133,7 @@ export const usePersistedDevicePreferences = (
for (const [deviceKey, devices, selectedDevice, isMute] of [
[
'camera',
cameraState.devices,
cameraDevices || [],
cameraState.selectedDevice,
cameraState.isMute,
],
Expand Down Expand Up @@ -161,7 +164,7 @@ export const usePersistedDevicePreferences = (
[
applyingState,
callingState,
cameraState.devices,
cameraDevices,
cameraState.isMute,
cameraState.selectedDevice,
key,
Expand Down
18 changes: 11 additions & 7 deletions sample-apps/react/react-dogfood/components/Lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ export const Lobby = ({ onJoin, mode = 'regular' }: LobbyProps) => {
)}
>
<div className="rd__lobby-video-preview">
<VideoPreview
DisabledVideoPreview={
hasBrowserMediaPermission
? DisabledVideoPreview
: AllowBrowserPermissions
}
/>
{settings?.video.enabled ? (
<VideoPreview
DisabledVideoPreview={
hasBrowserMediaPermission
? DisabledVideoPreview
: AllowBrowserPermissions
}
/>
) : (
<DisabledVideoPreview />
)}
<div className="rd__lobby-media-toggle">
<ToggleAudioPreviewButton Menu={null} />
{settings?.video.enabled && (
Expand Down
Loading