session-desktop/ts/components/ContactListItem.tsx
Audric Ackermann 72c96ea998
remove most of the SessionProtocol unused stuff
- prekeys
- SessionCipher
- LokiCipher
- endSession and the reset Session logic
- what we called Sessionprotocol manager (to keep track of session with
everyone)
2021-01-18 10:58:34 +11:00

74 lines
1.8 KiB
TypeScript

import React from 'react';
import classNames from 'classnames';
import { Avatar } from './Avatar';
import { Emojify } from './conversation/Emojify';
import { LocalizerType } from '../types/Util';
interface Props {
phoneNumber: string;
isMe?: boolean;
name?: string;
profileName?: string;
avatarPath?: string;
i18n: LocalizerType;
onClick?: () => void;
}
export class ContactListItem extends React.Component<Props> {
public renderAvatar() {
const { avatarPath, name, phoneNumber, profileName } = this.props;
const userName = name || profileName || phoneNumber;
return (
<Avatar
avatarPath={avatarPath}
name={userName}
size={36}
pubkey={phoneNumber}
/>
);
}
public render() {
const { i18n, name, onClick, isMe, phoneNumber, profileName } = this.props;
const title = name ? name : phoneNumber;
const displayName = isMe ? i18n('me') : title;
const profileElement =
!isMe && profileName && !name ? (
<span className="module-contact-list-item__text__profile-name">
~
<Emojify
text={profileName}
i18n={i18n}
key={`emojify-list-item-${phoneNumber}`}
/>
</span>
) : null;
const showNumber = isMe || name;
return (
<div
role="button"
onClick={onClick}
className={classNames(
'module-contact-list-item',
onClick ? 'module-contact-list-item--with-click-handler' : null
)}
>
{this.renderAvatar()}
<div className="module-contact-list-item__text">
<div className="module-contact-list-item__text__name">
<Emojify text={displayName} i18n={i18n} /> {profileElement}
</div>
</div>
</div>
);
}
}