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
		
	
| 
											7 years ago
										 | import React from 'react'; | ||
| 
											7 years ago
										 | import classNames from 'classnames'; | ||
| 
											4 years ago
										 | import { useConversationUsername, useIsMe } from '../../hooks/useParamSelector'; | ||
|  | import { Avatar, AvatarSize } from '../avatar/Avatar'; | ||
|  | import { Emojify } from '../conversation/Emojify'; | ||
| 
											7 years ago
										 | 
 | ||
| 
											4 years ago
										 | type Props = { | ||
| 
											4 years ago
										 |   pubkey: string; | ||
| 
											7 years ago
										 |   onClick?: () => void; | ||
| 
											4 years ago
										 | }; | ||
|  | 
 | ||
|  | 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} /> | ||
| 
											7 years ago
										 |         </div> | ||
|  |       </div> | ||
| 
											4 years ago
										 |     </div> | ||
|  |   ); | ||
|  | }; |