2018-06-27 22:53:49 +02:00
|
|
|
import React from 'react';
|
2018-07-07 02:48:14 +02:00
|
|
|
import classNames from 'classnames';
|
2018-06-27 22:53:49 +02:00
|
|
|
|
2021-03-26 05:24:56 +01:00
|
|
|
import { Avatar, AvatarSize } from './Avatar';
|
2018-06-27 22:53:49 +02:00
|
|
|
import { Emojify } from './conversation/Emojify';
|
2021-11-23 06:18:27 +01:00
|
|
|
import { useConversationUsername, useIsMe } from '../hooks/useParamSelector';
|
2018-06-27 22:53:49 +02:00
|
|
|
|
2021-11-23 06:18:27 +01:00
|
|
|
type Props = {
|
2021-09-17 08:41:04 +02:00
|
|
|
pubkey: string;
|
2018-06-27 22:53:49 +02:00
|
|
|
onClick?: () => void;
|
2021-11-23 06:18:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const AvatarItem = (props: { pubkey: string }) => {
|
|
|
|
const { pubkey } = props;
|
|
|
|
|
|
|
|
return <Avatar size={AvatarSize.S} pubkey={pubkey} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ContactListItem = (props: Props) => {
|
|
|
|
const { onClick, pubkey } = props;
|
|
|
|
|
|
|
|
const name = useConversationUsername(pubkey);
|
|
|
|
const isMe = useIsMe(pubkey);
|
|
|
|
|
|
|
|
const title = name ? name : pubkey;
|
|
|
|
const displayName = isMe ? window.i18n('me') : title;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
role="button"
|
|
|
|
onClick={onClick}
|
|
|
|
className={classNames(
|
|
|
|
'module-contact-list-item',
|
|
|
|
onClick ? 'module-contact-list-item--with-click-handler' : null
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<AvatarItem pubkey={pubkey} />
|
|
|
|
<div className="module-contact-list-item__text">
|
|
|
|
<div className="module-contact-list-item__text__name">
|
|
|
|
<Emojify text={displayName} />
|
2018-06-27 22:53:49 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-23 06:18:27 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|