-
Notifications
You must be signed in to change notification settings - Fork 39
/
RemoteAudioMute.tsx
27 lines (24 loc) · 959 Bytes
/
RemoteAudioMute.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React, { useContext } from 'react'
import BtnTemplate from '../BtnTemplate'
import PropsContext, { remoteTrackState, UIKitUser } from '../../PropsContext'
import RtmContext, { mutingDevice } from '../../RtmContext'
function RemoteAudioMute(props: { UIKitUser: UIKitUser }) {
const { styleProps } = useContext(PropsContext)
const { remoteBtnStyles } = styleProps || {}
const { sendMuteRequest, uidMap } = useContext(RtmContext)
const { muteRemoteAudio } = remoteBtnStyles || {}
const { UIKitUser } = props
const isMuted = UIKitUser.hasAudio === remoteTrackState.no
return UIKitUser.uid !== 0 && uidMap[UIKitUser.uid] ? (
<div>
<BtnTemplate
style={muteRemoteAudio}
name={UIKitUser.hasAudio === remoteTrackState.subbed ? 'mic' : 'micOff'}
onClick={() =>
sendMuteRequest(mutingDevice.microphone, UIKitUser.uid, !isMuted)
}
/>
</div>
) : null
}
export default RemoteAudioMute