@@ -186,13 +186,15 @@ export function useConversationWith(agentToDispatch: string | RoomAgentDispatch,
186186 } ;
187187 } , [ room , emitter ] ) ;
188188
189- const { localParticipant, cameraTrack, microphoneTrack } = useLocalParticipant ( { room } ) ;
189+ const { localParticipant } = useLocalParticipant ( { room } ) ;
190+ const cameraPublication = localParticipant . getTrackPublication ( Track . Source . Camera ) ;
190191 const localCamera = useMemo ( ( ) => {
191- return cameraTrack ? { source : Track . Source . Camera as const , participant : localParticipant , publication : microphoneTrack } : null ;
192- } , [ localParticipant , microphoneTrack ] ) ;
192+ return ! cameraPublication ?. isMuted ? { source : Track . Source . Camera as const , participant : localParticipant , publication : cameraPublication } : null ;
193+ } , [ localParticipant , cameraPublication , cameraPublication ?. isMuted ] ) ;
194+ const microphonePublication = localParticipant . getTrackPublication ( Track . Source . Microphone ) ;
193195 const localMicrophone = useMemo ( ( ) => {
194- return microphoneTrack ? { source : Track . Source . Microphone as const , participant : localParticipant , publication : microphoneTrack } : null ;
195- } , [ localParticipant , microphoneTrack ] ) ;
196+ return ! microphonePublication ?. isMuted ? { source : Track . Source . Microphone as const , participant : localParticipant , publication : microphonePublication } : null ;
197+ } , [ localParticipant , microphonePublication , microphonePublication ?. isMuted ] ) ;
196198
197199 const conversationState = useMemo ( ( ) : ConversationStateConnecting | ConversationStateConnected | ConversationStateDisconnected => {
198200 const common : ConversationStateCommon = {
@@ -248,7 +250,7 @@ export function useConversationWith(agentToDispatch: string | RoomAgentDispatch,
248250 } ,
249251 } ;
250252 }
251- } , [ options . credentials , room , emitter , roomConnectionState , localParticipant ] ) ;
253+ } , [ options . credentials , room , emitter , roomConnectionState , localParticipant , localCamera , localMicrophone ] ) ;
252254 useEffect ( ( ) => {
253255 emitter . emit ( ConversationEvent . ConnectionStateChanged , conversationState . connectionState ) ;
254256 } , [ emitter , conversationState . connectionState ] ) ;
0 commit comments