@@ -22,7 +22,6 @@ import { log } from '@livekit/components-core';
2222import { ParticipantPlaceholder } from '../assets/images' ;
2323import { useMediaDevices , usePersistentUserChoices } from '../hooks' ;
2424import { useWarnAboutMissingStyles } from '../hooks/useWarnAboutMissingStyles' ;
25- import { defaultUserChoices } from '@livekit/components-core' ;
2625import { roomOptionsStringifyReplacer } from '../utils' ;
2726
2827/**
@@ -231,17 +230,6 @@ export function PreJoin({
231230 videoProcessor,
232231 ...htmlProps
233232} : PreJoinProps ) {
234- const [ userChoices , setUserChoices ] = React . useState ( defaultUserChoices ) ;
235-
236- // TODO: Remove and pipe `defaults` object directly into `usePersistentUserChoices` once we fully switch from type `LocalUserChoices` to `UserChoices`.
237- const partialDefaults : Partial < LocalUserChoices > = {
238- ...( defaults . audioDeviceId !== undefined && { audioDeviceId : defaults . audioDeviceId } ) ,
239- ...( defaults . videoDeviceId !== undefined && { videoDeviceId : defaults . videoDeviceId } ) ,
240- ...( defaults . audioEnabled !== undefined && { audioEnabled : defaults . audioEnabled } ) ,
241- ...( defaults . videoEnabled !== undefined && { videoEnabled : defaults . videoEnabled } ) ,
242- ...( defaults . username !== undefined && { username : defaults . username } ) ,
243- } ;
244-
245233 const {
246234 userChoices : initialUserChoices ,
247235 saveAudioInputDeviceId,
@@ -250,21 +238,19 @@ export function PreJoin({
250238 saveVideoInputEnabled,
251239 saveUsername,
252240 } = usePersistentUserChoices ( {
253- defaults : partialDefaults ,
241+ defaults,
254242 preventSave : ! persistUserChoices ,
255243 preventLoad : ! persistUserChoices ,
256244 } ) ;
257245
246+ const [ userChoices , setUserChoices ] = React . useState ( initialUserChoices ) ;
247+
258248 // Initialize device settings
259- const [ audioEnabled , setAudioEnabled ] = React . useState < boolean > ( initialUserChoices . audioEnabled ) ;
260- const [ videoEnabled , setVideoEnabled ] = React . useState < boolean > ( initialUserChoices . videoEnabled ) ;
261- const [ audioDeviceId , setAudioDeviceId ] = React . useState < string > (
262- initialUserChoices . audioDeviceId ,
263- ) ;
264- const [ videoDeviceId , setVideoDeviceId ] = React . useState < string > (
265- initialUserChoices . videoDeviceId ,
266- ) ;
267- const [ username , setUsername ] = React . useState ( initialUserChoices . username ) ;
249+ const [ audioEnabled , setAudioEnabled ] = React . useState < boolean > ( userChoices . audioEnabled ) ;
250+ const [ videoEnabled , setVideoEnabled ] = React . useState < boolean > ( userChoices . videoEnabled ) ;
251+ const [ audioDeviceId , setAudioDeviceId ] = React . useState < string > ( userChoices . audioDeviceId ) ;
252+ const [ videoDeviceId , setVideoDeviceId ] = React . useState < string > ( userChoices . videoDeviceId ) ;
253+ const [ username , setUsername ] = React . useState ( userChoices . username ) ;
268254
269255 // Save user choices to persistent storage.
270256 React . useEffect ( ( ) => {
0 commit comments