// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { ReactNode } from 'react'; import React, { useEffect } from 'react'; import type { ConversationType } from '../../state/ducks/conversations'; import type { LocalizerType, ThemeType } from '../../types/Util'; import type { PreferredBadgeSelectorType } from '../../state/selectors/badges'; import { assertDev } from '../../util/assert'; import { Avatar, AvatarSize } from '../Avatar'; import { ContactName } from './ContactName'; import { SharedGroupNames } from '../SharedGroupNames'; import { UserText } from '../UserText'; import { I18n } from '../I18n'; export type PropsType = Readonly<{ children?: ReactNode; conversation: ConversationType; getPreferredBadge: PreferredBadgeSelectorType; i18n: LocalizerType; onClick?: () => void; toggleSignalConnectionsModal: () => void; updateSharedGroups: (conversationId: string) => void; theme: ThemeType; oldName: string | undefined; isSignalConnection: boolean; }>; export function ContactSpoofingReviewDialogPerson({ children, conversation, getPreferredBadge, i18n, onClick, toggleSignalConnectionsModal, updateSharedGroups, theme, oldName, isSignalConnection, }: PropsType): JSX.Element { assertDev( conversation.type === 'direct', ' expected a direct conversation' ); useEffect(() => { // Kick off the expensive hydration of the current sharedGroupNames updateSharedGroups(conversation.id); }, [conversation.id, updateSharedGroups]); const newName = conversation.profileName || conversation.title; let callout: JSX.Element | undefined; if (oldName && oldName !== newName) { callout = (
, newName: , }} />
); } const name = ( ); const contents = ( <>
{onClick ? ( ) : ( name )} {callout} {conversation.phoneNumber ? (
{conversation.phoneNumber}
) : null} {isSignalConnection ? (
) : null}
{conversation.sharedGroupNames?.length ? ( ) : ( i18n( 'icu:ContactSpoofingReviewDialog__group__members__no-shared-groups' ) )}
{children}
); return (
{contents}
); }