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