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() {