@@ -14,12 +14,13 @@ import {
1414 selectPreferredCameraId ,
1515 selectSpeakerState ,
1616} from '@proton/meet/store/slices/deviceManagementSlice/selectors' ;
17+ import type { DeviceKind } from '@proton/meet/store/slices/deviceManagementSlice/types' ;
1718import { filterDevices , getDefaultDevice , isDefaultDevice } from '@proton/meet/utils/deviceUtils' ;
1819import isTruthy from '@proton/utils/isTruthy' ;
1920
20- import { useStableCallback } from '../../hooks/useStableCallback' ;
21- import type { SwitchActiveDevice } from '../../types' ;
22- import { supportsSetSinkId } from '../../utils/browser' ;
21+ import { useStableCallback } from '../../../ hooks/useStableCallback' ;
22+ import type { SwitchActiveDevice , ToggleAudioType , ToggleVideoType } from '../ ../../types' ;
23+ import { supportsSetSinkId } from '../../../ utils/browser' ;
2324
2425const dynamicDeviceUpdate = ( {
2526 deviceList,
@@ -80,28 +81,8 @@ interface DeviceIdSets {
8081}
8182
8283interface UseDynamicDeviceHandlingParams {
83- toggleVideo : ( {
84- isEnabled,
85- videoDeviceId,
86- forceUpdate,
87- preserveCache,
88- updateUserIntent,
89- } : {
90- isEnabled ?: boolean ;
91- videoDeviceId ?: string ;
92- forceUpdate ?: boolean ;
93- preserveCache ?: boolean ;
94- updateUserIntent ?: boolean ;
95- } ) => Promise < boolean | undefined > ;
96- toggleAudio : ( {
97- isEnabled,
98- audioDeviceId,
99- preserveCache,
100- } : {
101- isEnabled ?: boolean ;
102- audioDeviceId ?: string ;
103- preserveCache ?: boolean ;
104- } ) => Promise < boolean | undefined > ;
84+ toggleVideo : ToggleVideoType ;
85+ toggleAudio : ToggleAudioType ;
10586 switchActiveDevice : SwitchActiveDevice ;
10687}
10788
@@ -110,13 +91,15 @@ export const useDynamicDeviceHandling = ({
11091 toggleVideo,
11192 switchActiveDevice,
11293} : UseDynamicDeviceHandlingParams ) => {
94+ const room = useRoomContext ( ) ;
95+
11396 const activeMicrophoneDeviceId = useMeetSelector ( selectActiveMicrophoneId ) ;
11497 const activeAudioOutputDeviceId = useMeetSelector ( selectActiveAudioOutputId ) ;
11598 const activeCameraDeviceId = useMeetSelector ( selectActiveCameraId ) ;
99+
116100 const preferredCameraId = useMeetSelector ( selectPreferredCameraId ) ;
117101 const microphoneState = useMeetSelector ( selectMicrophoneState ) ;
118102 const speakerState = useMeetSelector ( selectSpeakerState ) ;
119- const room = useRoomContext ( ) ;
120103
121104 const previousDevices = useRef < {
122105 microphones : MediaDeviceInfo [ ] ;
@@ -146,7 +129,7 @@ export const useDynamicDeviceHandling = ({
146129 }
147130
148131 const handleDeviceChange = useStableCallback ( async ( ) => {
149- const getLocalDevicesWithErrorHandling = async ( deviceType : 'audioinput' | 'videoinput' | 'audiooutput' ) => {
132+ const getLocalDevicesWithErrorHandling = async ( deviceType : DeviceKind ) => {
150133 try {
151134 return await Room . getLocalDevices ( deviceType , false ) ;
152135 } catch ( error ) {
@@ -253,7 +236,6 @@ export const useDynamicDeviceHandling = ({
253236
254237 void toggleVideo ( {
255238 videoDeviceId : newDeviceId ,
256- forceUpdate : true ,
257239 preserveCache : true ,
258240 updateUserIntent : false ,
259241 } ) ;
0 commit comments