From bb8ce5fc3b47a332dba7d653bdda3fd9a46fd838 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 4 Sep 2024 17:10:12 +1000 Subject: [PATCH] fix: copy accountId & copy button on messageInfo did not write anything --- .../message-info/OverlayMessageInfo.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ts/components/conversation/right-panel/overlay/message-info/OverlayMessageInfo.tsx b/ts/components/conversation/right-panel/overlay/message-info/OverlayMessageInfo.tsx index 1782e91cf..814d191d2 100644 --- a/ts/components/conversation/right-panel/overlay/message-info/OverlayMessageInfo.tsx +++ b/ts/components/conversation/right-panel/overlay/message-info/OverlayMessageInfo.tsx @@ -22,6 +22,7 @@ import { deleteMessagesById } from '../../../../../interactions/conversations/un import { PubKey } from '../../../../../session/types'; import { useMessageAttachments, + useMessageAuthor, useMessageBody, useMessageDirection, useMessageIsDeletable, @@ -191,7 +192,7 @@ function useMessageInfo(messageId: string | undefined) { return details; } -type WithMessageIdOpt = { messageId?: string }; +type WithMessageIdOpt = { messageId: string }; /** * Always shown, even if the message has no body so we always have at least one item in the PanelButtonGroup @@ -234,22 +235,22 @@ function ReplyToMessageButton({ messageId }: WithMessageIdOpt) { ); } -function CopySenderSessionId() { +function CopySenderSessionId({ messageId }: WithMessageIdOpt) { const isGroupOrCommunity = useSelectedIsGroupOrCommunity(); const isPrivate = useSelectedIsPrivate(); const isPublic = useSelectedIsPublic(); - const selectedConvo = useSelectedConversationKey(); + const senderId = useMessageAuthor(messageId); const isGroup = isGroupOrCommunity && !isPublic; - const isPrivateButNotBlinded = selectedConvo && isPrivate && !PubKey.isBlinded(selectedConvo); + const isPrivateButNotBlinded = senderId && isPrivate && !PubKey.isBlinded(senderId); - if (selectedConvo && (isGroup || isPrivateButNotBlinded)) { + if (senderId && (isGroup || isPrivateButNotBlinded)) { return ( { - clipboard.writeText(selectedConvo); + clipboard.writeText(senderId); ToastUtils.pushCopiedToClipBoard(); }} dataTestId="copy-sender-from-details" @@ -363,9 +364,9 @@ export const OverlayMessageInfo = () => { {/* CopyMessageBodyButton is always shown so the PanelButtonGroup always has at least one item */} - - - + + + {hasErrors && direction === 'outgoing' && (