File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { useMaybeRoomContext } from '../../context' ;
2+ import { useEnsureRoom } from '../../context' ;
33import { useStartAudio } from '../../hooks' ;
44import { Room } from 'livekit-client' ;
55
@@ -28,9 +28,8 @@ export const StartAudio: (
2828 props : AllowAudioPlaybackProps & React . RefAttributes < HTMLButtonElement > ,
2929) => React . ReactNode = /* @__PURE__ */ React . forwardRef < HTMLButtonElement , AllowAudioPlaybackProps > (
3030 function StartAudio ( { label = 'Allow Audio' , ...props } : AllowAudioPlaybackProps , ref ) {
31- const room = useMaybeRoomContext ( ) ;
32- const roomFallback = React . useMemo ( ( ) => props . room ?? room ?? new Room ( ) , [ ] ) ;
33- const { mergedProps } = useStartAudio ( { room : roomFallback , props } ) ;
31+ const room = useEnsureRoom ( props . room ) ;
32+ const { mergedProps } = useStartAudio ( { room, props } ) ;
3433
3534 return (
3635 < button ref = { ref } { ...mergedProps } >
Original file line number Diff line number Diff line change 11import { activeSpeakerObserver } from '@livekit/components-core' ;
22import * as React from 'react' ;
3- import { useMaybeRoomContext } from '../context' ;
3+ import { useEnsureRoom } from '../context' ;
44import { useObservableState } from './internal' ;
55import { Room } from 'livekit-client' ;
66
@@ -14,10 +14,9 @@ import { Room } from 'livekit-client';
1414 * @public
1515 */
1616export function useSpeakingParticipants ( room ?: Room ) {
17- const roomContext = useMaybeRoomContext ( ) ;
18- const roomFallback = React . useMemo ( ( ) => room ?? roomContext ?? new Room ( ) , [ room , roomContext ] ) ;
17+ const ensuredRoom = useEnsureRoom ( room ) ;
1918
20- const speakerObserver = React . useMemo ( ( ) => activeSpeakerObserver ( roomFallback ) , [ roomFallback ] ) ;
21- const activeSpeakers = useObservableState ( speakerObserver , roomFallback . activeSpeakers ) ;
19+ const speakerObserver = React . useMemo ( ( ) => activeSpeakerObserver ( ensuredRoom ) , [ ensuredRoom ] ) ;
20+ const activeSpeakers = useObservableState ( speakerObserver , ensuredRoom . activeSpeakers ) ;
2221 return activeSpeakers ;
2322}
You can’t perform that action at this time.
0 commit comments