fix: copy account id on right click on msg too
							parent
							
								
									0a1806a37b
								
							
						
					
					
						commit
						802fe71629
					
				@ -0,0 +1,28 @@
 | 
			
		||||
import { Item } from 'react-contexify';
 | 
			
		||||
import { useIsPrivate } from '../../../../hooks/useParamSelector';
 | 
			
		||||
import { copyPublicKeyByConvoId } from '../../../../interactions/conversationInteractions';
 | 
			
		||||
import { Localizer } from '../../../basic/Localizer';
 | 
			
		||||
import { showCopyAccountIdAction } from '.';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Can be used to copy the conversation AccountID or the message's author sender'id.
 | 
			
		||||
 * Depending on what the pubkey is
 | 
			
		||||
 */
 | 
			
		||||
export const CopyAccountIdMenuItem = ({ pubkey }: { pubkey: string }): JSX.Element | null => {
 | 
			
		||||
  const isPrivate = useIsPrivate(pubkey);
 | 
			
		||||
 | 
			
		||||
  // we want to show the copyId for communities only
 | 
			
		||||
 | 
			
		||||
  if (showCopyAccountIdAction({ isPrivate, pubkey })) {
 | 
			
		||||
    return (
 | 
			
		||||
      <Item
 | 
			
		||||
        onClick={() => {
 | 
			
		||||
          void copyPublicKeyByConvoId(pubkey);
 | 
			
		||||
        }}
 | 
			
		||||
      >
 | 
			
		||||
        <Localizer token="accountIDCopy" />
 | 
			
		||||
      </Item>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
  return null;
 | 
			
		||||
};
 | 
			
		||||
@ -0,0 +1,11 @@
 | 
			
		||||
import { PubKey } from '../../../../session/types';
 | 
			
		||||
 | 
			
		||||
export function showCopyAccountIdAction({
 | 
			
		||||
  isPrivate,
 | 
			
		||||
  pubkey,
 | 
			
		||||
}: {
 | 
			
		||||
  isPrivate: boolean;
 | 
			
		||||
  pubkey: string;
 | 
			
		||||
}) {
 | 
			
		||||
  return isPrivate && !PubKey.isBlinded(pubkey);
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,24 @@
 | 
			
		||||
import { Item } from 'react-contexify';
 | 
			
		||||
import { showCopyCommunityUrlMenuItem } from '.';
 | 
			
		||||
import { useIsPublic } from '../../../../hooks/useParamSelector';
 | 
			
		||||
import { copyPublicKeyByConvoId } from '../../../../interactions/conversationInteractions';
 | 
			
		||||
import { Localizer } from '../../../basic/Localizer';
 | 
			
		||||
 | 
			
		||||
export const CopyCommunityUrlMenuItem = ({ convoId }: { convoId: string }): JSX.Element | null => {
 | 
			
		||||
  const isPublic = useIsPublic(convoId);
 | 
			
		||||
 | 
			
		||||
  // we want to show the copyId for communities only
 | 
			
		||||
 | 
			
		||||
  if (showCopyCommunityUrlMenuItem({ isPublic })) {
 | 
			
		||||
    return (
 | 
			
		||||
      <Item
 | 
			
		||||
        onClick={() => {
 | 
			
		||||
          void copyPublicKeyByConvoId(convoId);
 | 
			
		||||
        }}
 | 
			
		||||
      >
 | 
			
		||||
        <Localizer token="communityUrlCopy" />
 | 
			
		||||
      </Item>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
  return null;
 | 
			
		||||
};
 | 
			
		||||
@ -0,0 +1,3 @@
 | 
			
		||||
export function showCopyCommunityUrlMenuItem({ isPublic }: { isPublic: boolean }) {
 | 
			
		||||
  return isPublic;
 | 
			
		||||
}
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue