From c7da2a84d928fa77556387c7e38b6a5d7801eabd Mon Sep 17 00:00:00 2001 From: lukasIO Date: Tue, 22 Oct 2024 10:37:28 +0200 Subject: [PATCH] Fix initial device selection when mounting useMediaDeviceSelect --- packages/core/src/observables/room.ts | 1 - packages/react/src/hooks/useMediaDeviceSelect.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core/src/observables/room.ts b/packages/core/src/observables/room.ts index 1094f35d7..de266811e 100644 --- a/packages/core/src/observables/room.ts +++ b/packages/core/src/observables/room.ts @@ -249,7 +249,6 @@ export function createActiveDeviceObservable(room: Room, kind: MediaDeviceKind) log.debug('activeDeviceObservable | RoomEvent.ActiveDeviceChanged', { kind, deviceId }); return deviceId; }), - startWith(room.getActiveDevice(kind)), ); } diff --git a/packages/react/src/hooks/useMediaDeviceSelect.ts b/packages/react/src/hooks/useMediaDeviceSelect.ts index 19d3dc44b..614959e35 100644 --- a/packages/react/src/hooks/useMediaDeviceSelect.ts +++ b/packages/react/src/hooks/useMediaDeviceSelect.ts @@ -63,7 +63,7 @@ export function useMediaDeviceSelect({ React.useEffect(() => { const listener = activeDeviceObservable.subscribe((deviceId) => { - if (deviceId) { + if (deviceId && deviceId !== currentDeviceId) { log.info('setCurrentDeviceId', deviceId); setCurrentDeviceId(deviceId); }