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