diff --git a/src/hooks/useAudioDeviceSelection.ts b/src/hooks/useAudioDeviceSelection.ts index d2f85534c5..0181556140 100644 --- a/src/hooks/useAudioDeviceSelection.ts +++ b/src/hooks/useAudioDeviceSelection.ts @@ -42,7 +42,9 @@ export const useAudioDeviceSelection = ( if (shouldRequestPermissionsRef.current) { shouldRequestPermissionsRef.current = false; requestMediaPermissions(false).then((stream: MediaStream | undefined) => { - MediaDeviceHandler.getDevices().then(({ audioinput }) => { + MediaDeviceHandler.getDevices().then((devices) => { + if (!devices) return; + const { audioinput } = devices; MediaDeviceHandler.getDefaultDevice(audioinput); const deviceFromSettings = MediaDeviceHandler.getAudioInput(); const device = diff --git a/src/hooks/usePublicRoomDirectory.ts b/src/hooks/usePublicRoomDirectory.ts index d58b799d93..a49c231723 100644 --- a/src/hooks/usePublicRoomDirectory.ts +++ b/src/hooks/usePublicRoomDirectory.ts @@ -166,9 +166,10 @@ export const usePublicRoomDirectory = (): { }, [protocols]); useEffect(() => { - localStorage.setItem(LAST_SERVER_KEY, config?.roomServer); - if (config?.instanceId) { - localStorage.setItem(LAST_INSTANCE_KEY, config?.instanceId); + if (!config) return; + localStorage.setItem(LAST_SERVER_KEY, config.roomServer); + if (config.instanceId) { + localStorage.setItem(LAST_INSTANCE_KEY, config.instanceId); } else { localStorage.removeItem(LAST_INSTANCE_KEY); }