// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useCallback, useEffect, useMemo } from 'react'; import { Modal } from './Modal'; import type { LocalizerType } from '../types/I18N'; import { Avatar, AvatarSize } from './Avatar'; import type { PendingUserActionPayloadType } from '../state/ducks/calling'; import type { ConversationType } from '../state/ducks/conversations'; import { InContactsIcon } from './InContactsIcon'; import { isInSystemContacts } from '../util/isInSystemContacts'; import { ThemeType } from '../types/Util'; import { Theme } from '../util/theme'; import { UserText } from './UserText'; import { SharedGroupNames } from './SharedGroupNames'; export type CallLinkPendingParticipantModalProps = { readonly i18n: LocalizerType; readonly conversation: ConversationType; readonly approveUser: (payload: PendingUserActionPayloadType) => void; readonly denyUser: (payload: PendingUserActionPayloadType) => void; readonly onClose: () => void; readonly toggleAboutContactModal: (conversationId: string) => void; readonly updateSharedGroups: (conversationId: string) => void; }; export function CallLinkPendingParticipantModal({ i18n, conversation, approveUser, denyUser, onClose, toggleAboutContactModal, updateSharedGroups, }: CallLinkPendingParticipantModalProps): JSX.Element { useEffect(() => { // Kick off the expensive hydration of the current sharedGroupNames updateSharedGroups(conversation.id); }, [conversation.id, updateSharedGroups]); const serviceId = useMemo(() => { return conversation.serviceId; }, [conversation]); const handleApprove = useCallback(() => { approveUser({ serviceId }); onClose(); }, [approveUser, onClose, serviceId]); const handleDeny = useCallback(() => { denyUser({ serviceId }); onClose(); }, [denyUser, onClose, serviceId]); return (
{conversation.sharedGroupNames?.length ? ( ) : ( i18n('icu:no-groups-in-common-warning') )}
); }