From 616e952f8ef678eb23cac44bc29e46875cb7a1d6 Mon Sep 17 00:00:00 2001 From: Beaudan Date: Thu, 8 Aug 2019 15:09:54 +1000 Subject: [PATCH] Add right click option to public chat messages to copy pubkey of sender --- js/models/messages.js | 12 ++++++++++++ ts/components/conversation/Message.tsx | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/js/models/messages.js b/js/models/messages.js index 3102ee915..d9027cf9c 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -678,6 +678,7 @@ this.getSource() === this.OUR_NUMBER, onCopyText: () => this.copyText(), + onCopyPubKey: () => this.copyPubKey(), onReply: () => this.trigger('reply', this), onRetrySend: () => this.retrySend(), onShowDetail: () => this.trigger('show-message-detail', this), @@ -964,6 +965,17 @@ }; }, + copyPubKey() { + if (this.isIncoming()) { + clipboard.writeText(this.get('source')); + } else { + clipboard.writeText(this.OUR_NUMBER); + } + window.Whisper.events.trigger('showToast', { + message: i18n('copiedPublicKey'), + }); + }, + copyText() { clipboard.writeText(this.get('body')); window.Whisper.events.trigger('showToast', { diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index dba0d52de..8ed5fa4f3 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -97,6 +97,7 @@ export interface Props { onRetrySend?: () => void; onDownload?: (isDangerous: boolean) => void; onDelete?: () => void; + onCopyPubKey?: () => void; onShowDetail: () => void; } @@ -826,6 +827,8 @@ export class Message extends React.PureComponent { onReply, onRetrySend, onShowDetail, + onCopyPubKey, + isPublic, i18n, } = this.props; @@ -888,6 +891,9 @@ export class Message extends React.PureComponent { {i18n('deleteMessage')} ) : null} + {isPublic ? ( + {i18n('copyPublicKey')} + ) : null} ); }