From e8433a88abef63533e09cb50470dcaf4d51630c9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 14 Jun 2022 18:02:32 -0500 Subject: [PATCH] ChatBox: click lock button to initiate key exchange --- app/soapbox/features/chats/components/chat_box.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/soapbox/features/chats/components/chat_box.js b/app/soapbox/features/chats/components/chat_box.js index b8910920f..036c398e0 100644 --- a/app/soapbox/features/chats/components/chat_box.js +++ b/app/soapbox/features/chats/components/chat_box.js @@ -15,6 +15,7 @@ import { Stack, HStack, IconButton } from 'soapbox/components/ui'; import UploadProgress from 'soapbox/features/compose/components/upload-progress'; import UploadButton from 'soapbox/features/compose/components/upload_button'; import { truncateFilename } from 'soapbox/utils/media'; +import { initPgpKey } from 'soapbox/utils/pgp'; import ChatMessageList from './chat_message_list'; @@ -25,6 +26,7 @@ const messages = defineMessages({ const mapStateToProps = (state, { chatId }) => ({ me: state.get('me'), + account: state.getIn(['accounts', state.me]), chat: state.getIn(['chats', 'items', chatId]), chatMessageIds: state.getIn(['chat_message_lists', chatId], ImmutableOrderedSet()), }); @@ -169,13 +171,24 @@ class ChatBox extends ImmutablePureComponent { ); } + sendPublicKey = async() => { + const { dispatch, chatId, account } = this.props; + const { publicKey } = await initPgpKey(account.fqn); + + const params = { + content: publicKey, + }; + + dispatch(sendChatMessage(chatId, params)); + } + renderEncryptionButton = () => { return ( {}} + onClick={this.sendPublicKey} transparent /> );