// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only /* eslint-disable react/no-array-index-key */ import React from 'react'; import { createPortal } from 'react-dom'; import { Avatar } from './Avatar'; import { ContactName } from './conversation/ContactName'; import { LocalizerType } from '../types/Util'; import { GroupCallRemoteParticipantType } from '../types/Calling'; export type PropsType = { readonly i18n: LocalizerType; readonly onClose: () => void; readonly participants: Array; }; export const CallingParticipantsList = React.memo( ({ i18n, onClose, participants }: PropsType) => { const [root, setRoot] = React.useState(null); React.useEffect(() => { const div = document.createElement('div'); document.body.appendChild(div); setRoot(div); return () => { document.body.removeChild(div); setRoot(null); }; }, []); if (!root) { return null; } return createPortal(
{!participants.length && i18n('calling__in-this-call--zero')} {participants.length === 1 && i18n('calling__in-this-call--one')} {participants.length > 1 && i18n('calling__in-this-call--many', [ String(participants.length), ])}
    {participants.map( (participant: GroupCallRemoteParticipantType, index: number) => (
  • {participant.isSelf ? ( {i18n('you')} ) : ( )}
    {!participant.hasRemoteAudio ? ( ) : null} {!participant.hasRemoteVideo ? ( ) : null}
  • ) )}
, root ); } );