2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-06-27 20:53:49 +00:00
|
|
|
import React from 'react';
|
2018-07-07 00:48:14 +00:00
|
|
|
import classNames from 'classnames';
|
2018-06-27 20:53:49 +00:00
|
|
|
|
2021-01-26 01:01:19 +00:00
|
|
|
import { About } from './conversation/About';
|
2018-09-27 00:23:17 +00:00
|
|
|
import { Avatar } from './Avatar';
|
2018-06-27 20:53:49 +00:00
|
|
|
import { Emojify } from './conversation/Emojify';
|
2020-07-24 01:35:32 +00:00
|
|
|
import { InContactsIcon } from './InContactsIcon';
|
2018-06-27 20:53:49 +00:00
|
|
|
|
2020-08-13 20:53:45 +00:00
|
|
|
import { LocalizerType } from '../types/Util';
|
|
|
|
import { ColorType } from '../types/Colors';
|
2018-06-27 20:53:49 +00:00
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
type Props = {
|
2021-01-26 01:01:19 +00:00
|
|
|
about?: string;
|
2018-06-27 20:53:49 +00:00
|
|
|
avatarPath?: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
color?: ColorType;
|
2019-01-14 21:49:58 +00:00
|
|
|
i18n: LocalizerType;
|
2020-09-09 02:25:05 +00:00
|
|
|
isAdmin?: boolean;
|
|
|
|
isMe?: boolean;
|
|
|
|
name?: string;
|
2018-06-27 20:53:49 +00:00
|
|
|
onClick?: () => void;
|
2020-09-09 02:25:05 +00:00
|
|
|
phoneNumber?: string;
|
|
|
|
profileName?: string;
|
|
|
|
title: string;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2018-06-27 20:53:49 +00:00
|
|
|
|
|
|
|
export class ContactListItem extends React.Component<Props> {
|
2020-09-12 00:46:52 +00:00
|
|
|
public renderAvatar(): JSX.Element {
|
2018-09-27 00:23:17 +00:00
|
|
|
const {
|
|
|
|
avatarPath,
|
|
|
|
i18n,
|
|
|
|
color,
|
|
|
|
name,
|
|
|
|
phoneNumber,
|
|
|
|
profileName,
|
2020-07-24 01:35:32 +00:00
|
|
|
title,
|
2018-09-27 00:23:17 +00:00
|
|
|
} = this.props;
|
2018-06-27 20:53:49 +00:00
|
|
|
|
|
|
|
return (
|
2018-09-27 00:23:17 +00:00
|
|
|
<Avatar
|
|
|
|
avatarPath={avatarPath}
|
|
|
|
color={color}
|
|
|
|
conversationType="direct"
|
|
|
|
i18n={i18n}
|
|
|
|
name={name}
|
|
|
|
phoneNumber={phoneNumber}
|
|
|
|
profileName={profileName}
|
2020-07-24 01:35:32 +00:00
|
|
|
title={title}
|
2019-10-04 18:06:17 +00:00
|
|
|
size={52}
|
2018-09-27 00:23:17 +00:00
|
|
|
/>
|
2018-06-27 20:53:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-12 00:46:52 +00:00
|
|
|
public render(): JSX.Element {
|
2021-01-26 01:01:19 +00:00
|
|
|
const { about, i18n, isAdmin, isMe, name, onClick, title } = this.props;
|
2018-06-27 20:53:49 +00:00
|
|
|
|
2020-03-09 20:56:11 +00:00
|
|
|
const displayName = isMe ? i18n('you') : title;
|
2020-07-24 01:35:32 +00:00
|
|
|
const shouldShowIcon = Boolean(name);
|
2018-06-27 20:53:49 +00:00
|
|
|
|
|
|
|
return (
|
2019-11-07 21:36:16 +00:00
|
|
|
<button
|
2018-06-27 20:53:49 +00:00
|
|
|
onClick={onClick}
|
2018-07-07 00:48:14 +00:00
|
|
|
className={classNames(
|
2018-06-27 20:53:49 +00:00
|
|
|
'module-contact-list-item',
|
|
|
|
onClick ? 'module-contact-list-item--with-click-handler' : null
|
|
|
|
)}
|
2020-09-12 00:46:52 +00:00
|
|
|
type="button"
|
2018-06-27 20:53:49 +00:00
|
|
|
>
|
2018-09-27 00:23:17 +00:00
|
|
|
{this.renderAvatar()}
|
2018-06-27 20:53:49 +00:00
|
|
|
<div className="module-contact-list-item__text">
|
2020-09-09 02:25:05 +00:00
|
|
|
<div className="module-contact-list-item__left">
|
|
|
|
<div className="module-contact-list-item__text__name">
|
|
|
|
<Emojify text={displayName} />
|
|
|
|
{shouldShowIcon ? (
|
|
|
|
<span>
|
|
|
|
{' '}
|
|
|
|
<InContactsIcon i18n={i18n} />
|
|
|
|
</span>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
<div className="module-contact-list-item__text__additional-data">
|
2021-01-26 01:01:19 +00:00
|
|
|
<About text={about} />
|
2020-09-09 02:25:05 +00:00
|
|
|
</div>
|
2018-06-27 20:53:49 +00:00
|
|
|
</div>
|
2020-09-09 02:25:05 +00:00
|
|
|
{isAdmin ? (
|
|
|
|
<div className="module-contact-list-item__admin">
|
|
|
|
{i18n('GroupV2--admin')}
|
|
|
|
</div>
|
|
|
|
) : null}
|
2018-06-27 20:53:49 +00:00
|
|
|
</div>
|
2019-11-07 21:36:16 +00:00
|
|
|
</button>
|
2018-06-27 20:53:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|