summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-07-25 14:32:28 -0500
committerRobin Jarry <robin@jarry.cc>2022-07-26 22:21:21 +0200
commita1a549cb1e10d18e071695249b995e2dddfdac2a (patch)
tree962463b0955b3fc16c90b8067ac0ed6b917354e9
parentd941960fe175fd89b08b5a3f1bd073e0ecaf2d59 (diff)
downloadaerc-a1a549cb1e10d18e071695249b995e2dddfdac2a.zip
check-mail: fix startup when default folder is empty
check-mail was triggered to run at startup after a Done:FetchHeaders message. This message would only occur if there were messages in the default folder. In the case where there are no messages, check-mail would not run at startup as intended. Run check-mail even if there are no messages found in the default folder at startup. Fixes: https://todo.sr.ht/~rjarry/aerc/60 Reported-by: ~foutrelis Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--widgets/account.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 3172a30..ff51636 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -276,9 +276,8 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
case *types.RemoveDirectory:
acct.dirlist.UpdateList(nil)
case *types.FetchMessageHeaders:
- if acct.newConn && acct.AccountConfig().CheckMail.Minutes() > 0 {
- acct.newConn = false
- acct.CheckMail()
+ if acct.newConn {
+ acct.checkMailOnStartup()
}
}
case *types.DirectoryInfo:
@@ -307,6 +306,9 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store.Update(msg)
acct.SetStatus(statusline.Threading(store.ThreadedView()))
}
+ if acct.newConn && len(msg.Uids) == 0 {
+ acct.checkMailOnStartup()
+ }
case *types.DirectoryThreaded:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
if acct.msglist.Store() == nil {
@@ -315,6 +317,9 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store.Update(msg)
acct.SetStatus(statusline.Threading(store.ThreadedView()))
}
+ if acct.newConn && len(msg.Threads) == 0 {
+ acct.checkMailOnStartup()
+ }
case *types.FullMessage:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
store.Update(msg)
@@ -418,6 +423,13 @@ func (acct *AccountView) CheckMail() {
})
}
+func (acct *AccountView) checkMailOnStartup() {
+ if acct.AccountConfig().CheckMail.Minutes() > 0 {
+ acct.newConn = false
+ acct.CheckMail()
+ }
+}
+
func (acct *AccountView) CheckMailTimer(d time.Duration) {
ticker := time.NewTicker(d)
go func() {