aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/account.go
diff options
context:
space:
mode:
authorkt programs <ktprograms@gmail.com>2022-09-25 09:55:21 +0800
committerRobin Jarry <robin@jarry.cc>2022-09-29 17:14:07 +0200
commit9c0e54f9d9afb5f4a9d91ca9766fc2ef2cfd82de (patch)
tree2e2e6fd94233c3cb73d2b7fe9797ec603d9ff461 /widgets/account.go
parentbf2bf8c242cbddce684acd55743caa9b749f6d46 (diff)
downloadaerc-9c0e54f9d9afb5f4a9d91ca9766fc2ef2cfd82de.tar.gz
imap: stop checkmail if there are pending actions
Pass message containing remaining directories to check. Account widget will recursively call CheckMail with the remaining directories until a Done message is returned. Only needed for IMAP worker as other workers run check-mail-cmd in a separate goroutine. Suggested-By: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: kt programs <ktprograms@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 382a07a8..c131f335 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -438,12 +438,25 @@ func (acct *AccountView) CheckMail() {
Timeout: acct.acct.CheckMailTimeout,
}
acct.checkingMail = true
- acct.worker.PostAction(msg, func(_ types.WorkerMessage) {
- acct.SetStatus(statusline.ConnectionActivity(""))
- acct.Lock()
- acct.checkingMail = false
- acct.Unlock()
- })
+
+ var cb func(types.WorkerMessage)
+ cb = func(response types.WorkerMessage) {
+ dirsMsg, ok := response.(*types.CheckMailDirectories)
+ if ok {
+ checkMailMsg := &types.CheckMail{
+ Directories: dirsMsg.Directories,
+ Command: acct.acct.CheckMailCmd,
+ Timeout: acct.acct.CheckMailTimeout,
+ }
+ acct.worker.PostAction(checkMailMsg, cb)
+ } else { // Done
+ acct.SetStatus(statusline.ConnectionActivity(""))
+ acct.Lock()
+ acct.checkingMail = false
+ acct.Unlock()
+ }
+ }
+ acct.worker.PostAction(msg, cb)
}
// CheckMailReset resets the check-mail timer