fix(@desktop/chat): open 121 chat by pasting chat key of existing mutual contact

This commit is contained in:
mprakhov 2022-12-06 13:45:22 +02:00 committed by Mykhailo Prakhov
parent c801c869e6
commit d60a4b0c97
2 changed files with 27 additions and 18 deletions

View File

@ -96,6 +96,7 @@ Item {
TextInput { TextInput {
id: edit id: edit
property bool pasteOperation: false
Layout.minimumWidth: 4 Layout.minimumWidth: 4
Layout.fillHeight: true Layout.fillHeight: true
verticalAlignment: Text.AlignVCenter 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: { Keys.onPressed: {
if (event.matches(StandardKey.Paste)) { if (event.matches(StandardKey.Paste)) {
event.accepted = true pasteOperation = true
const previousText = text; root.suggestionsDialog.forceHide = true
const previousSelectedText = selectedText;
paste()
if (previousText === "" || previousSelectedText.length === previousText.length)
root.textPasted(text)
return;
} }
if (suggestionsDialog.visible) { 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 // ensure edit cursor is visible

View File

@ -89,30 +89,31 @@ MembersSelectorBase {
enabled: root.visible enabled: root.visible
target: root.rootStore.contactsStore.mainModuleInst target: root.rootStore.contactsStore.mainModuleInst
onResolvedENS: { onResolvedENS: {
if (resolvedPubKey === "") {
if (resolvedPubKey === "") root.suggestionsDialog.forceHide = false
return return
}
const contactDetails = Utils.getContactDetailsAsJson(resolvedPubKey, false) const contactDetails = Utils.getContactDetailsAsJson(resolvedPubKey, false)
if (contactDetails.publicKey === root.rootStore.contactsStore.myPublicKey) if (contactDetails.publicKey === root.rootStore.contactsStore.myPublicKey ||
return; contactDetails.isBlocked) {
root.suggestionsDialog.forceHide = false
if (contactDetails.isBlocked) return
return; };
if (contactDetails.isContact) { if (contactDetails.isContact) {
if (d.addMember(contactDetails.publicKey, contactDetails.displayName)) root.rootStore.mainModuleInst.switchTo(root.rootStore.getMySectionId(), contactDetails.publicKey)
root.cleanup()
return return
} }
if (root.model.count === 0) { if (root.model.count === 0) {
root.suggestionsDialog.forceHide = true
Global.openContactRequestPopup(contactDetails.publicKey, Global.openContactRequestPopup(contactDetails.publicKey,
popup => popup.closed.connect(root.rejected)) popup => popup.closed.connect(root.rejected))
return return
} }
root.suggestionsDialog.forceHide = false
} }
} }
} }