signal-desktop/ts/state/smart/ContactName.tsx

38 lines
1 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// 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 type { StateType } from '../reducer';
2020-09-09 02:25:05 +00:00
import { ContactName } from '../../components/conversation/ContactName';
import { getIntl } from '../selectors/user';
import type { GetConversationByIdType } from '../selectors/conversations';
import { getConversationSelector } from '../selectors/conversations';
2020-09-09 02:25:05 +00:00
import type { LocalizerType } from '../../types/Util';
2020-09-09 02:25:05 +00:00
type ExternalProps = {
conversationId: string;
};
2022-11-18 00:45:19 +00:00
export function SmartContactName(props: ExternalProps): JSX.Element {
2020-09-09 02:25:05 +00:00
const { conversationId } = props;
const i18n = useSelector<StateType, LocalizerType>(getIntl);
const getConversation = useSelector<StateType, GetConversationByIdType>(
getConversationSelector
);
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}
title={conversation.title}
/>
);
2022-11-18 00:45:19 +00:00
}