Returning early in searchFilterCards fn

This commit is contained in:
Bharat 2021-04-01 13:26:58 +05:30
parent d8390a8bf3
commit 0b02ddfc4b

View file

@ -200,10 +200,18 @@ class MutableBoardTree implements BoardTree {
return cards.filter((card: Card) => {
const searchTextInCardTitle: boolean = card.title?.toLocaleLowerCase().includes(searchText)
const searchTextInProperties: boolean = Object.values(card.properties).
map((el: string) => el.toLowerCase().includes(searchText)).
some((el: boolean) => el)
return searchTextInCardTitle || searchTextInProperties
if (searchTextInCardTitle) {
return true
}
for (const property in card.properties) {
if (
Object.prototype.hasOwnProperty.call(card.properties, property) &&
card.properties[property].toLowerCase().includes(searchText)
) {
return true
}
}
return false
})
}