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

32 lines
887 B
TypeScript
Raw Normal View History

2020-09-08 19:25:05 -07: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;
};
export const SmartContactName: React.ComponentType<ExternalProps> = props => {
2020-09-08 19:25:05 -07: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-08 19:25:05 -07:00
return <ContactName i18n={i18n} {...conversation} />;
};