chore(settings/messaging): improve contact filter expressions

This commit is contained in:
Patryk Osmaczko 2022-08-17 08:44:02 +02:00 committed by osmaczko
parent beb4658633
commit 29add2fbc9
1 changed files with 4 additions and 5 deletions

View File

@ -68,10 +68,8 @@ Item {
}
function searchPredicate(name, pubkey) {
if (root.searchString === "") return true
let lowerCaseSearchString = root.searchString.toLowerCase()
let compressedPubkey = Utils.getCompressedPk(pubkey)
const lowerCaseSearchString = root.searchString.toLowerCase()
const compressedPubkey = Utils.getCompressedPk(pubkey)
return name.toLowerCase().includes(lowerCaseSearchString) ||
pubkey.toLowerCase().includes(lowerCaseSearchString) ||
@ -81,9 +79,10 @@ Item {
filters: [
ExpressionFilter { expression: filteredModel.panelUsagePredicate(model.isVerified) },
ExpressionFilter {
enabled: root.searchString !== ""
expression: {
root.searchString // ensure expression is reevaluated when searchString changes
filteredModel.searchPredicate(model.displayName, model.pubKey)
return filteredModel.searchPredicate(model.displayName, model.pubKey)
}
}
]