fix(member-selector): Adds filter suggestions by chat key pasted in input

Fixes: #9881
This commit is contained in:
Boris Melnik 2023-05-15 21:22:15 +03:00
parent e0acf0f195
commit e34d28f881
2 changed files with 17 additions and 3 deletions

View File

@ -35,6 +35,7 @@ MembersSelectorBase {
edit.onTextChanged: {
// When edited, give a small delay in case next character is printed soon
contactLookupDelayTimer.start()
root.pastedChatKey = ""
}
onTextPasted: (text) => {
@ -62,7 +63,6 @@ MembersSelectorBase {
property ListModel selectedMembers: ListModel {}
function lookupContact(value) {
value = Utils.dropUserLinkPrefix(value.trim())
if (Utils.isChatKey(value)) {
@ -94,7 +94,8 @@ MembersSelectorBase {
};
if (contactDetails.isContact) {
root.rootStore.mainModuleInst.switchTo(root.rootStore.getMySectionId(), contactDetails.publicKey)
root.pastedChatKey = contactDetails.publicKey
root.suggestionsDialog.forceHide = false
return
}

View File

@ -27,6 +27,8 @@ InlineSelectorPanel {
return localNickname || displayName || aliasName
}
property string pastedChatKey: ""
label.text: qsTr("To:")
warningLabel.text: qsTr("%1 USER LIMIT REACHED").arg(membersLimit)
warningLabel.visible: limitReached
@ -50,9 +52,13 @@ InlineSelectorPanel {
return true
}
function isPastedProfileLinkToContact(pubkey) {
return root.pastedChatKey === pubkey
}
filters: [
ExpressionFilter {
enabled: root.edit.text !== ""
enabled: root.edit.text !== "" && root.pastedChatKey == ""
expression: {
root.edit.text // ensure expression is reevaluated when edit.text changes
return _suggestionsModel.searchPredicate(model.displayName, model.localNickname, model.alias)
@ -63,6 +69,13 @@ InlineSelectorPanel {
root.model.count // ensure expression is reevaluated when members model changes
return _suggestionsModel.notAMemberPredicate(model.pubKey)
}
},
ExpressionFilter {
enabled: root.pastedChatKey != ""
expression: {
root.pastedChatKey // ensure expression is reevaluated when members model changes
return _suggestionsModel.isPastedProfileLinkToContact(model.pubKey)
}
}
]