update mute all buttons to avoid wildcards

This commit is contained in:
Jessica Mitchell 2022-02-18 16:33:12 -05:00
parent ea458c03eb
commit 11e0a1953f
1 changed files with 18 additions and 6 deletions

View File

@ -101,6 +101,22 @@ export const PeopleAside = () => {
return null; return null;
} }
async function muteAll(deviceType) {
let updatedParticipantList = {};
// Accommodate muting mics and cameras
const newSetting =
deviceType === 'video' ? { setVideo: false } : { setAudio: false };
for (let id in callObject.participants()) {
// Do not update the local participant's device (aka the instructor)
if (id === 'local') continue;
updatedParticipantList[id] = newSetting;
}
// Update all participants at once
callObject.updateParticipants(updatedParticipantList);
}
return ( return (
<Aside onClose={() => setShowAside(false)}> <Aside onClose={() => setShowAside(false)}>
<AsideHeader /> <AsideHeader />
@ -111,9 +127,7 @@ export const PeopleAside = () => {
fullWidth fullWidth
size="tiny" size="tiny"
variant="outline-gray" variant="outline-gray"
onClick={() => onClick={() => muteAll('audio')}
callObject.updateParticipants({ '*': { setAudio: false } })
}
> >
Mute all mics Mute all mics
</Button> </Button>
@ -121,9 +135,7 @@ export const PeopleAside = () => {
fullWidth fullWidth
size="tiny" size="tiny"
variant="outline-gray" variant="outline-gray"
onClick={() => onClick={() => muteAll('video')}
callObject.updateParticipants({ '*': { setVideo: false } })
}
> >
Mute all cams Mute all cams
</Button> </Button>