import React, { useCallback } from 'react'; import { Aside } from '@custom/shared/components/Aside'; import Button from '@custom/shared/components/Button'; import { useCallState } from '@custom/shared/contexts/CallProvider'; import { useParticipants } from '@custom/shared/contexts/ParticipantsProvider'; import { useUIState } from '@custom/shared/contexts/UIStateProvider'; import { ReactComponent as IconCamOff } from '@custom/shared/icons/camera-off-sm.svg'; import { ReactComponent as IconCamOn } from '@custom/shared/icons/camera-on-sm.svg'; import { ReactComponent as IconMicOff } from '@custom/shared/icons/mic-off-sm.svg'; import { ReactComponent as IconMicOn } from '@custom/shared/icons/mic-on-sm.svg'; import PropTypes from 'prop-types'; import AsideHeader from '../App/AsideHeader'; export const PEOPLE_ASIDE = 'people'; const PersonRow = ({ participant, isOwner = false }) => (
{participant.name} {participant.isLocal && '(You)'}
{!isOwner ? ( <> {participant.isCamMuted ? : } {participant.isMicMuted ? : } ) : ( <> )}
); PersonRow.propTypes = { participant: PropTypes.object, isOwner: PropTypes.bool, }; export const PeopleAside = () => { const { callObject } = useCallState(); const { showAside, setShowAside } = useUIState(); const { participants, isOwner } = useParticipants(); const muteAll = useCallback( (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); }, [callObject] ); const handleMuteAllAudio = () => muteAll('audio'); const handleMuteAllVideo = () => muteAll('video'); if (!showAside || showAside !== PEOPLE_ASIDE) { return null; } return ( ); }; export default PeopleAside;