maildir: make checkmail update directory counts

Non-selected folders will now have their total/unread/new counts updated
in the background when a check-mail happens.

Signed-off-by: Ben Cohen <ben@bencohen.net>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Ben Cohen 2022-10-18 12:03:09 -04:00 committed by Robin Jarry
parent bad694e466
commit f7a9454441

View file

@ -733,6 +733,20 @@ func (w *Worker) handleCheckMail(msg *types.CheckMail) {
if err != nil {
w.err(msg, fmt.Errorf("checkmail: error running command: %w", err))
} else {
dirs, err := w.c.ListFolders()
if err != nil {
w.err(msg, fmt.Errorf("failed listing directories: %w", err))
}
for _, name := range dirs {
err := w.c.SyncNewMail(w.c.Dir(name))
if err != nil {
w.err(msg, fmt.Errorf("could not sync new mail: %w", err))
}
dirInfo := w.getDirectoryInfo(name)
w.worker.PostMessage(&types.DirectoryInfo{
Info: dirInfo,
}, nil)
}
w.done(msg)
}
}