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
48479856
Commit
48479856
authored
4 years ago
by
Oliver Wiese
Browse files
Options
Downloads
Patches
Plain Diff
fix mailhandler: decrease number of fetched mails on first fetch
parent
a4205a29
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enzevalos_iphone/MailHandler.swift
+35
-18
35 additions, 18 deletions
enzevalos_iphone/MailHandler.swift
with
35 additions
and
18 deletions
enzevalos_iphone/MailHandler.swift
+
35
−
18
View file @
48479856
...
@@ -395,7 +395,7 @@
...
@@ -395,7 +395,7 @@
}
}
private
func
loadMessagesFromServer
(
_
uids
:
MCOIndexSet
,
folderPath
:
String
,
maxLoad
:
Int
=
MailHandler
.
MAXMAILS
,
completionCallback
:
@escaping
((
_
error
:
MailServerConnectionError
?)
->
()))
{
private
func
loadMessagesFromServer
(
_
uids
:
MCOIndexSet
,
folderPath
:
String
,
maxLoad
:
Int
=
MailHandler
.
MAXMAILS
,
completionCallback
:
@escaping
((
_
error
:
MailServerConnectionError
?)
->
()))
{
guard
IMAPSession
!=
nil
else
{
guard
let
session
=
IMAPSession
else
{
completionCallback
(
MailServerConnectionError
.
NoData
)
completionCallback
(
MailServerConnectionError
.
NoData
)
return
return
}
}
...
@@ -405,7 +405,7 @@
...
@@ -405,7 +405,7 @@
}
}
// First fetch -> get flags
// First fetch -> get flags
let
requestKind
=
MCOIMAPMessagesRequestKind
(
rawValue
:
MCOIMAPMessagesRequestKind
.
headers
.
rawValue
|
MCOIMAPMessagesRequestKind
.
flags
.
rawValue
)
let
requestKind
=
MCOIMAPMessagesRequestKind
(
rawValue
:
MCOIMAPMessagesRequestKind
.
headers
.
rawValue
|
MCOIMAPMessagesRequestKind
.
flags
.
rawValue
)
let
fetchOperation
:
MCOIMAPFetchMessagesOperation
=
se
lf
.
IMAPSe
ssion
!
.
fetchMessagesOperation
(
withFolder
:
folderPath
,
requestKind
:
requestKind
,
uids
:
uids
)
let
fetchOperation
:
MCOIMAPFetchMessagesOperation
=
session
.
fetchMessagesOperation
(
withFolder
:
folderPath
,
requestKind
:
requestKind
,
uids
:
uids
)
fetchOperation
.
extraHeaders
=
MailHandler
.
extraHeaders
fetchOperation
.
extraHeaders
=
MailHandler
.
extraHeaders
fetchOperation
.
start
{[
unowned
self
]
(
err
,
msg
,
vanished
)
->
Void
in
fetchOperation
.
start
{[
unowned
self
]
(
err
,
msg
,
vanished
)
->
Void
in
...
@@ -566,27 +566,44 @@
...
@@ -566,27 +566,44 @@
}
}
private
func
initFolder
(
folderPath
:
String
,
completionCallback
:
@escaping
((
MailServerConnectionError
?)
->
()))
{
private
func
initFolder
(
folderPath
:
String
,
completionCallback
:
@escaping
((
MailServerConnectionError
?)
->
()))
{
let
requestKind
=
MCOIMAPMessagesRequestKind
(
rawValue
:
MCOIMAPMessagesRequestKind
.
headers
.
rawValue
)
guard
let
session
=
IMAPSession
else
{
let
uids
=
MCOIndexSet
(
range
:
MCORangeMake
(
1
,
UINT64_MAX
))
self
.
errorhandling
(
error
:
.
ConnectionError
,
originalCall
:
{
self
.
initFolder
(
folderPath
:
folderPath
,
completionCallback
:
completionCallback
)},
completionCallback
:
completionCallback
)
let
toFetchIDs
=
MCOIndexSet
()
return
}
let
fetchOperation
:
MCOIMAPFetchMessagesOperation
=
self
.
IMAPSession
!.
fetchMessagesOperation
(
withFolder
:
folderPath
,
requestKind
:
requestKind
,
uids
:
uids
)
session
.
folderStatusOperation
(
folderPath
)?
.
start
({
error
,
status
in
fetchOperation
.
start
{[
unowned
self
]
(
err
,
msg
,
vanished
)
->
Void
in
if
let
error
=
error
{
guard
err
==
nil
else
{
let
conerror
=
MailServerConnectionError
.
findErrorCode
(
error
:
error
)
let
conerror
=
MailServerConnectionError
.
findErrorCode
(
error
:
err
!
)
self
.
errorhandling
(
error
:
conerror
,
originalCall
:
{
self
.
initFolder
(
folderPath
:
folderPath
,
completionCallback
:
completionCallback
)},
completionCallback
:
completionCallback
)
self
.
errorhandling
(
error
:
conerror
,
originalCall
:
{
self
.
initFolder
(
folderPath
:
folderPath
,
completionCallback
:
completionCallback
)},
completionCallback
:
completionCallback
)
return
return
}
}
if
let
msgs
=
msg
{
guard
let
status
=
status
else
{
FolderRecord
.
lastDate
(
folder
:
folderPath
,
date
:
Date
())
for
message
in
msgs
{
toFetchIDs
.
add
(
UInt64
(
message
.
uid
))
}
self
.
loadMessagesFromServer
(
toFetchIDs
,
folderPath
:
folderPath
,
maxLoad
:
50
,
completionCallback
:
completionCallback
)
}
else
{
completionCallback
(
nil
)
completionCallback
(
nil
)
return
}
}
}
let
requestKind
=
MCOIMAPMessagesRequestKind
(
rawValue
:
MCOIMAPMessagesRequestKind
.
headers
.
rawValue
)
let
min
=
max
(
status
.
uidNext
-
1000
,
1
)
let
uids
=
MCOIndexSet
(
range
:
MCORangeMake
(
UInt64
(
min
),
UInt64
(
status
.
uidNext
)))
let
toFetchIDs
=
MCOIndexSet
()
let
fetchOperation
:
MCOIMAPFetchMessagesOperation
=
session
.
fetchMessagesOperation
(
withFolder
:
folderPath
,
requestKind
:
requestKind
,
uids
:
uids
)
fetchOperation
.
start
{[
unowned
self
]
(
err
,
msg
,
vanished
)
->
Void
in
guard
err
==
nil
else
{
let
conerror
=
MailServerConnectionError
.
findErrorCode
(
error
:
err
!
)
self
.
errorhandling
(
error
:
conerror
,
originalCall
:
{
self
.
initFolder
(
folderPath
:
folderPath
,
completionCallback
:
completionCallback
)},
completionCallback
:
completionCallback
)
return
}
if
let
msgs
=
msg
{
FolderRecord
.
lastDate
(
folder
:
folderPath
,
date
:
Date
())
for
message
in
msgs
{
toFetchIDs
.
add
(
UInt64
(
message
.
uid
))
}
self
.
loadMessagesFromServer
(
toFetchIDs
,
folderPath
:
folderPath
,
maxLoad
:
50
,
completionCallback
:
completionCallback
)
}
else
{
completionCallback
(
nil
)
}
}
})
}
}
private
func
initInbox
(
completionCallback
:
@escaping
((
MailServerConnectionError
?)
->
()))
{
private
func
initInbox
(
completionCallback
:
@escaping
((
MailServerConnectionError
?)
->
()))
{
...
...
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