Skip to content

Commit

Permalink
Fix initial device selection when mounting useMediaDeviceSelect (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Oct 22, 2024
1 parent 370c610 commit 5e31441
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/lemon-eggs-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@livekit/components-core": patch
"@livekit/components-react": patch
---

Fix initial device selection when mounting useMediaDeviceSelect
1 change: 0 additions & 1 deletion packages/core/src/observables/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export function createActiveDeviceObservable(room: Room, kind: MediaDeviceKind)
log.debug('activeDeviceObservable | RoomEvent.ActiveDeviceChanged', { kind, deviceId });
return deviceId;
}),
startWith(room.getActiveDevice(kind)),
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useMediaDeviceSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5e31441

Please sign in to comment.