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.
		
		
		
		
		
			
		
			
	
	
		
			113 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			113 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			TypeScript
		
	
| 
											5 years ago
										 | import React from 'react'; | ||
|  | import { animation, Menu } from 'react-contexify'; | ||
|  | 
 | ||
|  | import { | ||
|  |   getBlockMenuItem, | ||
|  |   getClearNicknameMenuItem, | ||
|  |   getCopyMenuItem, | ||
|  |   getDeleteContactMenuItem, | ||
|  |   getDeleteMessagesMenuItem, | ||
|  |   getInviteContactMenuItem, | ||
|  |   getLeaveGroupMenuItem, | ||
|  | } from './Menu'; | ||
|  | 
 | ||
|  | export type PropsContextConversationItem = { | ||
|  |   triggerId: string; | ||
|  |   type: 'group' | 'direct'; | ||
|  |   isMe: boolean; | ||
|  |   isPublic?: boolean; | ||
|  |   isRss?: boolean; | ||
|  |   isClosable?: boolean; | ||
|  |   isBlocked?: boolean; | ||
|  |   hasNickname?: boolean; | ||
|  |   isKickedFromGroup?: boolean; | ||
|  | 
 | ||
|  |   onDeleteMessages?: () => void; | ||
|  |   onDeleteContact?: () => void; | ||
|  |   onBlockContact?: () => void; | ||
|  |   onCopyPublicKey?: () => void; | ||
|  |   onUnblockContact?: () => void; | ||
|  |   onInviteContacts?: () => void; | ||
|  |   onClearNickname?: () => void; | ||
|  | }; | ||
|  | 
 | ||
|  | export const ConversationListItemContextMenu = ( | ||
|  |   props: PropsContextConversationItem | ||
|  | ) => { | ||
|  |   const { | ||
|  |     triggerId, | ||
|  |     isBlocked, | ||
|  |     isMe, | ||
|  |     isClosable, | ||
|  |     isRss, | ||
|  |     isPublic, | ||
|  |     hasNickname, | ||
|  |     type, | ||
|  |     isKickedFromGroup, | ||
|  |     onDeleteContact, | ||
|  |     onDeleteMessages, | ||
|  |     onBlockContact, | ||
|  |     onClearNickname, | ||
|  |     onCopyPublicKey, | ||
|  |     onUnblockContact, | ||
|  |     onInviteContacts, | ||
|  |   } = props; | ||
|  | 
 | ||
|  |   return ( | ||
|  |     <Menu id={triggerId} animation={animation.fade}> | ||
|  |       {getBlockMenuItem( | ||
|  |         isMe, | ||
|  |         type === 'direct', | ||
|  |         isBlocked, | ||
|  |         onBlockContact, | ||
|  |         onUnblockContact, | ||
|  |         window.i18n | ||
|  |       )} | ||
|  |       {/* {!isPublic && !isRss && !isMe ? ( | ||
|  |         <Item onClick={onChangeNickname}> | ||
|  |           {i18n('changeNickname')} | ||
|  |         </Item> | ||
|  |       ) : null} */} | ||
|  |       {getClearNicknameMenuItem( | ||
|  |         isPublic, | ||
|  |         isRss, | ||
|  |         isMe, | ||
|  |         hasNickname, | ||
|  |         onClearNickname, | ||
|  |         window.i18n | ||
|  |       )} | ||
|  |       {getCopyMenuItem( | ||
|  |         isPublic, | ||
|  |         isRss, | ||
|  |         type === 'group', | ||
|  |         onCopyPublicKey, | ||
|  |         window.i18n | ||
|  |       )} | ||
|  |       {getDeleteMessagesMenuItem(isPublic, onDeleteMessages, window.i18n)} | ||
|  |       {getInviteContactMenuItem( | ||
|  |         type === 'group', | ||
|  |         isPublic, | ||
|  |         onInviteContacts, | ||
|  |         window.i18n | ||
|  |       )} | ||
|  |       {getDeleteContactMenuItem( | ||
|  |         isMe, | ||
|  |         isClosable, | ||
|  |         type === 'group', | ||
|  |         isPublic, | ||
|  |         isRss, | ||
|  |         onDeleteContact, | ||
|  |         window.i18n | ||
|  |       )} | ||
|  |       {getLeaveGroupMenuItem( | ||
|  |         isKickedFromGroup, | ||
|  |         type === 'group', | ||
|  |         isPublic, | ||
|  |         isRss, | ||
|  |         onDeleteContact, | ||
|  |         window.i18n | ||
|  |       )} | ||
|  |     </Menu> | ||
|  |   ); | ||
|  | }; |