Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
do better string comparisons for filtering (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashei authored Mar 15, 2018
1 parent 9120163 commit c5ae068
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lockbox-ios/Presenter/ItemListPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ class ItemListPresenter {
return latest.items
}

let latestText = latest.text.lowercased()
return latest.items.filter { item -> Bool in
return item.entry.username?.lowercased().contains(latestText) ?? false
|| item.origins.first?.lowercased().contains(latestText) ?? false
|| item.title?.lowercased().contains(latestText) ?? false
return [item.entry.username, item.origins.first, item.title]
.flatMap { $0?.localizedCaseInsensitiveContains(latest.text) ?? false }
.reduce(false) { $0 || $1 }
}
}
.map { items -> [ItemSectionModel] in
Expand Down

0 comments on commit c5ae068

Please sign in to comment.