You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
| import React from 'react';
 | |
| import classNames from 'classnames';
 | |
| import { useConversationUsername, useIsMe } from '../../hooks/useParamSelector';
 | |
| import { Avatar, AvatarSize } from '../avatar/Avatar';
 | |
| import { Emojify } from '../conversation/Emojify';
 | |
| 
 | |
| type Props = {
 | |
|   pubkey: string;
 | |
|   onClick?: () => void;
 | |
| };
 | |
| 
 | |
| 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} />
 | |
|         </div>
 | |
|       </div>
 | |
|     </div>
 | |
|   );
 | |
| };
 |