aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-05-17 16:03:04 +0200
committerRobin Jarry <robin@jarry.cc>2024-07-01 00:09:16 +0200
commit588776f42574567f907c190a5ff089256b21e598 (patch)
tree011e78e52d4e70afeb6e11ffe315eb5aa45dc2e2 /app
parent0efcf2b3b08de22bcd5994a671c2b276db3488eb (diff)
downloadaerc-588776f42574567f907c190a5ff089256b21e598.tar.gz
imap: report errors from server
Avoid eternal spinner on the message list when the imap server advertises some message UIDs but fails to provide their headers when aerc asks from them. When an error occurs, or if some UIDs are not returned, make sure to report the errors to the message list UI. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
Diffstat (limited to 'app')
-rw-r--r--app/msglist.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/app/msglist.go b/app/msglist.go
index 24547b64..44367fb4 100644
--- a/app/msglist.go
+++ b/app/msglist.go
@@ -46,6 +46,7 @@ func (ml *MessageList) Invalidate() {
type messageRowParams struct {
uid uint32
needsHeaders bool
+ err error
uiConfig *config.UIConfig
styles []config.StyleObject
headers *mail.Header
@@ -115,6 +116,16 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
customDraw := func(t *ui.Table, r int, c *ui.Context) bool {
row := &t.Rows[r]
params, _ := row.Priv.(messageRowParams)
+ if params.err != nil {
+ var style vaxis.Style
+ if params.uid == store.SelectedUid() {
+ style = uiConfig.GetStyle(config.STYLE_ERROR)
+ } else {
+ style = uiConfig.GetStyleSelected(config.STYLE_ERROR)
+ }
+ ctx.Printf(0, r, style, "error: %s", params.err)
+ return true
+ }
if params.needsHeaders {
needsHeaders = append(needsHeaders, params.uid)
ml.spinner.Draw(ctx.Subcontext(0, r, c.Width(), 1))
@@ -198,9 +209,12 @@ func addMessage(
cells := make([]string, len(table.Columns))
params := messageRowParams{uid: uid, uiConfig: uiConfig}
- if msg == nil || msg.Envelope == nil {
+ if msg == nil || (msg.Envelope == nil && msg.Error == nil) {
params.needsHeaders = true
return table.AddRow(cells, params)
+ } else if msg.Error != nil {
+ params.err = msg.Error
+ return table.AddRow(cells, params)
}
if msg.Flags.Has(models.SeenFlag) {