File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
packages/react/src/components/controls Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @livekit/components-react " : patch
3+ ---
4+
5+ Only call onDeviceChange callback when non default device initially
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export const MediaDeviceSelect: (
6161 ref ,
6262 ) {
6363 const room = useMaybeRoomContext ( ) ;
64+ const previousActiveDeviceId = React . useRef < string > ( 'default' ) ;
6465 const handleError = React . useCallback (
6566 ( e : Error ) => {
6667 if ( room ) {
@@ -91,9 +92,10 @@ export const MediaDeviceSelect: (
9192 } , [ onDeviceListChange , devices ] ) ;
9293
9394 React . useEffect ( ( ) => {
94- if ( activeDeviceId && activeDeviceId !== '' ) {
95+ if ( activeDeviceId !== previousActiveDeviceId . current ) {
9596 onActiveDeviceChange ?.( activeDeviceId ) ;
9697 }
98+ previousActiveDeviceId . current = activeDeviceId ;
9799 } , [ activeDeviceId ] ) ;
98100
99101 const handleActiveDeviceChange = async ( deviceId : string ) => {
You can’t perform that action at this time.
0 commit comments