MCPcopy Create free account
hub / github.com/cloudflare/meet / MuteUserButton

Function MuteUserButton

app/components/MuteUserButton.tsx:18–98  ·  view source on GitHub ↗
({
	user,
	displayType = 'secondary',
	mutedDisplayType = 'danger',
})

Source from the content-addressed store, hash-verified

16}
17
18export const MuteUserButton: FC<MuteUserButtonProps> = ({
19 user,
20 displayType = 'secondary',
21 mutedDisplayType = 'danger',
22}) => {
23 const { room } = useRoomContext()
24 const { data } = useUserMetadata(user.name)
25
26 if (user.tracks.audioUnavailable) {
27 return (
28 <Tooltip content="Mic is unavailable. User cannot unmute.">
29 <Button disabled displayType="secondary">
30 <Icon type="micOff" className="text-red-700 dark:text-red-400" />
31 <VisuallyHidden>
32 User's mic is unavailable, cannot unmute.
33 </VisuallyHidden>
34 </Button>
35 </Tooltip>
36 )
37 }
38
39 return (
40 <AlertDialog.Root>
41 {user.tracks.audioEnabled ? (
42 <Tooltip content={`Mute ${data?.displayName}`}>
43 <AlertDialog.Trigger asChild>
44 <Button
45 displayType={displayType}
46 disabled={!user.tracks.audioEnabled}
47 >
48 <Icon type="micOn" />
49 </Button>
50 </AlertDialog.Trigger>
51 </Tooltip>
52 ) : (
53 <Tooltip content="Cannot unmute">
54 <Button displayType={mutedDisplayType} disabled>
55 <Icon type="micOff" />
56 </Button>
57 </Tooltip>
58 )}
59
60 <AlertDialog.Portal>
61 <AlertDialog.Overlay />
62 <AlertDialog.Content
63 // If we don't prevent the alert from restoring focus the tooltip
64 // will continue to show when we don't want it to.
65 onCloseAutoFocus={(e) => e.preventDefault()}
66 >
67 <AlertDialog.Title>Mute {data?.displayName}</AlertDialog.Title>
68 <AlertDialog.Description>
69 They will need to unmute themselves to be heard again.
70 </AlertDialog.Description>
71 <AlertDialog.Actions>
72 <AlertDialog.Cancel asChild>
73 <Button className="text-sm" displayType="secondary">
74 Cancel
75 </Button>

Callers

nothing calls this directly

Calls 2

useRoomContextFunction · 0.90
useUserMetadataFunction · 0.90

Tested by

no test coverage detected