Skip to content
Snippets Groups Projects
Commit 158204b6 authored by lazarog98's avatar lazarog98
Browse files

#238 add a comment

parent a557521f
No related branches found
No related tags found
1 merge request!27Resolve "Improve searching"
......@@ -275,15 +275,14 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
- searchText: the string we are looking for
*/
private func _filterContentForSearchText(_ searchText: String, scope: Int = 0) {
var records = [KeyRecord]()
records += folder.records.filter({ (record: KeyRecord) -> Bool in
let records = folder.records.filter({ (record: KeyRecord) -> Bool in
if scope == 0
{
return containsSearchTerms(content: record.name, searchText: searchText)
}
let mails = record.inboxMails
return mails.filter({ (mail: PersistentMail) -> Bool in
// concatenate all strings that fall in our scope
var str = ""
if scope == 1 || scope == 3
{
......@@ -304,48 +303,6 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
return containsSearchTerms(content: str, searchText: searchText)
}).count > 0
})
/*
if scope == 1 {
records += folder.records.filter({ (record: KeyRecord) -> Bool in
let mails = record.inboxMails
return mails.filter({ (mail: PersistentMail) -> Bool in
containsSearchTerms(content: mail.subject, searchText: searchText)
}).count > 0
})
}
if scope == 2 {
records += folder.records.filter({ (record: KeyRecord) -> Bool in
let mails = record.inboxMails
return mails.filter({ (mail: PersistentMail) -> Bool in
if let decryptedBody = mail.decryptedBody {
return containsSearchTerms(content: decryptedBody, searchText: searchText)
} else if !mail.isEncrypted {
return containsSearchTerms(content: mail.body, searchText: searchText)
}
return false
}).count > 0
})
}
if scope == 3
{
records += folder.records.filter({ (record: KeyRecord) -> Bool in
if containsSearchTerms(content: record.name, searchText: searchText)
{
return true
}
let mails = record.inboxMails
return mails.filter({ (mail: PersistentMail) -> Bool in
if let decryptedBody = mail.decryptedBody {
return containsSearchTerms(content: decryptedBody+(mail.subject ?? "")+record.name, searchText: searchText)
} else if !mail.isEncrypted {
return containsSearchTerms(content: (mail.body ?? "") + (mail.subject ?? "")+record.name, searchText: searchText)
}
return false
}).count > 0
})
}*/
filteredRecords = records.unique.sorted()
tableView.reloadData()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment