// Copyright 2023 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { Avatar, AvatarSize } from './Avatar'; import { ContactName } from './conversation/ContactName'; import type { ConversationsByDemuxIdType } from '../types/Calling'; import type { ServiceIdString } from '../types/ServiceId'; import type { LocalizerType } from '../types/Util'; import type { ConversationType } from '../state/ducks/conversations'; import { ModalHost } from './ModalHost'; import * as log from '../logging/log'; export type PropsType = { readonly i18n: LocalizerType; readonly onClose: () => void; readonly onLowerMyHand: () => void; readonly localDemuxId: number | undefined; readonly conversationsByDemuxId: ConversationsByDemuxIdType; readonly raisedHands: Set; readonly localHandRaised: boolean; }; export function CallingRaisedHandsList({ i18n, onClose, onLowerMyHand, localDemuxId, conversationsByDemuxId, raisedHands, localHandRaised, }: PropsType): JSX.Element | null { const ourServiceId: ServiceIdString | undefined = localDemuxId ? conversationsByDemuxId.get(localDemuxId)?.serviceId : undefined; const participants = React.useMemo>(() => { const serviceIds: Set = new Set(); const conversations: Array = []; raisedHands.forEach(demuxId => { const conversation = conversationsByDemuxId.get(demuxId); if (!conversation) { log.warn( 'CallingRaisedHandsList: Failed to get conversationsByDemuxId for demuxId', { demuxId } ); return; } const { serviceId } = conversation; if (serviceId) { if (serviceIds.has(serviceId)) { return; } serviceIds.add(serviceId); } conversations.push(conversation); }); return conversations; }, [raisedHands, conversationsByDemuxId]); return (
{i18n('icu:CallingRaisedHandsList__Title', { count: participants.length, })}
    {participants.map((participant: ConversationType, index: number) => (
  • {ourServiceId && participant.serviceId === ourServiceId ? ( {i18n('icu:you')} ) : ( )}
    {localHandRaised && ourServiceId && participant.serviceId === ourServiceId && ( )}
  • ))}
); }