Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
0736f05e
Commit
0736f05e
authored
5 years ago
by
lazarog98
Browse files
Options
Downloads
Patches
Plain Diff
Initial body search query w/ separated terms
parent
6a65c458
No related branches found
No related tags found
1 merge request
!27
Resolve "Improve searching"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enzevalos_iphone/InboxViewController.swift
+36
-4
36 additions, 4 deletions
enzevalos_iphone/InboxViewController.swift
with
36 additions
and
4 deletions
enzevalos_iphone/InboxViewController.swift
+
36
−
4
View file @
0736f05e
...
...
@@ -267,18 +267,50 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
}
}
/**
Function to be used to find mails that contain the search terms. All terms (separated by spaces) need to be contained in the search text.
- parameters:
- content: The String that will be searched
- searchText: Search terms (space-separated) that will be searched for
*/
private
func
containsSearchTerms
(
content
:
String
?,
searchText
:
String
)
->
Bool
{
if
searchText
==
""
{
return
true
///Case empty search
}
if
content
==
nil
{
return
false
///Case Mail has no body/subject
}
//var terms = searchText.characters.split(separator: " ")
let
terms
=
searchText
.
lowercased
()
.
components
(
separatedBy
:
" "
)
var
found
=
true
for
t
in
terms
{
found
=
found
&&
content
!.
lowercased
()
.
contains
(
t
)
}
return
found
}
/**
Filters emails by a user input string and scope
- parameters:
-scope: 0 =
*/
private
func
_filterContentForSearchText
(
_
searchText
:
String
,
scope
:
Int
=
0
)
{
var
records
=
[
KeyRecord
]()
if
scope
==
0
||
scope
==
3
{
records
+=
folder
.
records
.
filter
({
(
record
:
KeyRecord
)
->
Bool
in
return
record
.
name
.
lowercased
()
.
contains
(
searchText
.
lowercased
()
)
return
containsSearchTerms
(
content
:
record
.
name
,
searchText
:
searchText
)
})
}
if
scope
==
1
||
scope
==
3
{
records
+=
folder
.
records
.
filter
({
(
record
:
KeyRecord
)
->
Bool
in
let
mails
=
record
.
inboxMails
return
mails
.
filter
({
(
mail
:
PersistentMail
)
->
Bool
in
mail
.
subject
?
.
lowercased
()
.
contains
(
searchText
.
lowercased
())
??
false
containsSearchTerms
(
content
:
mail
.
subject
,
searchText
:
searchText
)
})
.
count
>
0
})
}
...
...
@@ -287,9 +319,9 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
let
mails
=
record
.
inboxMails
return
mails
.
filter
({
(
mail
:
PersistentMail
)
->
Bool
in
if
let
decryptedBody
=
mail
.
decryptedBody
{
return
decryptedBody
.
lowercased
()
.
contains
(
searchText
.
lowercased
()
)
return
containsSearchTerms
(
content
:
decryptedBody
,
searchText
:
searchText
)
}
else
if
!
mail
.
isEncrypted
{
return
mail
.
body
?
.
lowercased
()
.
contains
(
searchText
.
lowercased
())
??
false
return
containsSearchTerms
(
content
:
mail
.
body
,
searchText
:
searchText
)
}
return
false
})
.
count
>
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment