From d60a4b0c9727579ca5375dc60301b796d6de0a4c Mon Sep 17 00:00:00 2001 From: mprakhov Date: Tue, 6 Dec 2022 13:45:22 +0200 Subject: [PATCH] fix(@desktop/chat): open 121 chat by pasting chat key of existing mutual contact --- .../Chat/panels/InlineSelectorPanel.qml | 24 ++++++++++++------- .../Chat/views/MembersSelectorView.qml | 21 ++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/ui/app/AppLayouts/Chat/panels/InlineSelectorPanel.qml b/ui/app/AppLayouts/Chat/panels/InlineSelectorPanel.qml index 1ca44c8741..3190820e0e 100644 --- a/ui/app/AppLayouts/Chat/panels/InlineSelectorPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/InlineSelectorPanel.qml @@ -96,6 +96,7 @@ Item { TextInput { id: edit + property bool pasteOperation: false Layout.minimumWidth: 4 Layout.fillHeight: true verticalAlignment: Text.AlignVCenter @@ -119,17 +120,13 @@ Item { } } - onTextEdited: if (suggestionsDialog.forceHide) suggestionsDialog.forceHide = false; + onTextEdited: if (suggestionsDialog.forceHide && !pasteOperation) + suggestionsDialog.forceHide = false Keys.onPressed: { if (event.matches(StandardKey.Paste)) { - event.accepted = true - const previousText = text; - const previousSelectedText = selectedText; - paste() - if (previousText === "" || previousSelectedText.length === previousText.length) - root.textPasted(text) - return; + pasteOperation = true + root.suggestionsDialog.forceHide = true } if (suggestionsDialog.visible) { @@ -154,6 +151,17 @@ Item { } } } + + Keys.onReleased: { + if (event.matches(StandardKey.Paste)) { + event.accepted = true + pasteOperation = false + if (text) { + root.textPasted(text) + } + + } + } } // ensure edit cursor is visible diff --git a/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml b/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml index cc0296cfc7..6d76680438 100644 --- a/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml +++ b/ui/app/AppLayouts/Chat/views/MembersSelectorView.qml @@ -89,30 +89,31 @@ MembersSelectorBase { enabled: root.visible target: root.rootStore.contactsStore.mainModuleInst onResolvedENS: { - - if (resolvedPubKey === "") + if (resolvedPubKey === "") { + root.suggestionsDialog.forceHide = false return + } const contactDetails = Utils.getContactDetailsAsJson(resolvedPubKey, false) - if (contactDetails.publicKey === root.rootStore.contactsStore.myPublicKey) - return; - - if (contactDetails.isBlocked) - return; + if (contactDetails.publicKey === root.rootStore.contactsStore.myPublicKey || + contactDetails.isBlocked) { + root.suggestionsDialog.forceHide = false + return + }; if (contactDetails.isContact) { - if (d.addMember(contactDetails.publicKey, contactDetails.displayName)) - root.cleanup() + root.rootStore.mainModuleInst.switchTo(root.rootStore.getMySectionId(), contactDetails.publicKey) return } if (root.model.count === 0) { - root.suggestionsDialog.forceHide = true Global.openContactRequestPopup(contactDetails.publicKey, popup => popup.closed.connect(root.rejected)) return } + + root.suggestionsDialog.forceHide = false } } }