signal-desktop/ts/components/conversation/ContactName.tsx

41 lines
797 B
TypeScript
Raw Normal View History

// Copyright 2018-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
2020-07-24 01:35:32 +00:00
import { LocalizerType } from '../../types/Util';
import { Emojify } from './Emojify';
export type PropsType = {
2021-03-03 20:09:58 +00:00
firstName?: string;
i18n: LocalizerType;
module?: string;
name?: string;
phoneNumber?: string;
2021-03-03 20:09:58 +00:00
preferFirstName?: boolean;
profileName?: string;
2021-03-03 20:09:58 +00:00
title: string;
};
2021-03-03 20:09:58 +00:00
export const ContactName = ({
firstName,
module,
preferFirstName,
title,
}: PropsType): JSX.Element => {
2020-09-14 19:51:27 +00:00
const prefix = module || 'module-contact-name';
2021-03-03 20:09:58 +00:00
let text: string;
if (preferFirstName) {
text = firstName || title || '';
} else {
text = title || '';
}
2020-09-14 19:51:27 +00:00
return (
<span className={prefix} dir="auto">
2021-03-03 20:09:58 +00:00
<Emojify text={text} />
2020-09-14 19:51:27 +00:00
</span>
);
};