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

34 lines
853 B
TypeScript
Raw Normal View History

import React from 'react';
import { Emojify } from './Emojify';
2020-05-27 21:37:06 +00:00
export interface Props {
phoneNumber?: string;
name?: string;
profileName?: string;
module?: string;
}
export class ContactName extends React.Component<Props> {
public render() {
const { phoneNumber, name, profileName, module } = this.props;
const prefix = module ? module : 'module-contact-name';
const title = name ? name : phoneNumber;
const shouldShowProfile = Boolean(profileName && !name);
const profileElement = shouldShowProfile ? (
<span className={`${prefix}__profile-name`}>
~<Emojify text={profileName || ''} />
</span>
) : null;
return (
<span className={prefix} dir="auto">
<Emojify text={title || ''} />
{shouldShowProfile ? ' ' : null}
{profileElement}
</span>
);
}
}