Little refactoring
This commit is contained in:
parent
199310de86
commit
72991218d9
|
@ -40,7 +40,7 @@ open class EmailsFetcher(
|
||||||
open fun listenForNewEmails(account: EmailAccount, options: ListenForNewMailsOptions) = runBlocking {
|
open fun listenForNewEmails(account: EmailAccount, options: ListenForNewMailsOptions) = runBlocking {
|
||||||
try {
|
try {
|
||||||
connect(account) { store ->
|
connect(account) { store ->
|
||||||
val folder = store.getFolder(options.emailFolderName)
|
val folder = store.getFolder(options.emailFolderName) as IMAPFolder
|
||||||
folder.open(Folder.READ_ONLY)
|
folder.open(Folder.READ_ONLY)
|
||||||
|
|
||||||
val status = FetchEmailsStatus(options)
|
val status = FetchEmailsStatus(options)
|
||||||
|
@ -63,7 +63,7 @@ open class EmailsFetcher(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open suspend fun keepConnectionOpen(account: EmailAccount, folder: Folder, options: ListenForNewMailsOptions) {
|
protected open suspend fun keepConnectionOpen(account: EmailAccount, folder: IMAPFolder, options: ListenForNewMailsOptions) {
|
||||||
log.info { "Listening to new emails of ${account.username}" }
|
log.info { "Listening to new emails of ${account.username}" }
|
||||||
|
|
||||||
// Use IMAP IDLE to keep the connection alive
|
// Use IMAP IDLE to keep the connection alive
|
||||||
|
@ -73,7 +73,7 @@ open class EmailsFetcher(
|
||||||
folder.open(Folder.READ_ONLY)
|
folder.open(Folder.READ_ONLY)
|
||||||
}
|
}
|
||||||
|
|
||||||
(folder as IMAPFolder).idle()
|
folder.idle()
|
||||||
|
|
||||||
delay(250)
|
delay(250)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue