2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { StateType } from '../reducer';
|
|
|
|
|
|
|
|
import { ContactName } from '../../components/conversation/ContactName';
|
|
|
|
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import {
|
|
|
|
GetConversationByIdType,
|
|
|
|
getConversationSelector,
|
|
|
|
} from '../selectors/conversations';
|
|
|
|
|
|
|
|
import { LocalizerType } from '../../types/Util';
|
|
|
|
|
|
|
|
type ExternalProps = {
|
|
|
|
conversationId: string;
|
|
|
|
};
|
|
|
|
|
2020-09-14 21:56:35 +00:00
|
|
|
export const SmartContactName: React.ComponentType<ExternalProps> = props => {
|
2020-09-09 02:25:05 +00:00
|
|
|
const { conversationId } = props;
|
|
|
|
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
|
|
|
const getConversation = useSelector<StateType, GetConversationByIdType>(
|
|
|
|
getConversationSelector
|
|
|
|
);
|
|
|
|
|
2020-09-16 14:22:46 +00:00
|
|
|
const conversation = getConversation(conversationId) || {
|
|
|
|
title: i18n('unknownContact'),
|
|
|
|
};
|
2020-09-09 02:25:05 +00:00
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
return (
|
|
|
|
<ContactName
|
|
|
|
firstName={conversation.firstName}
|
|
|
|
i18n={i18n}
|
|
|
|
name={conversation.name}
|
|
|
|
phoneNumber={conversation.phoneNumber}
|
|
|
|
profileName={conversation.profileName}
|
|
|
|
title={conversation.title}
|
|
|
|
/>
|
|
|
|
);
|
2020-09-09 02:25:05 +00:00
|
|
|
};
|