diff options
-rw-r--r-- | widgets/msgviewer.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 19be7473..d168f456 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -77,7 +77,7 @@ func NewMessageViewer(acct *AccountView, hv.Name = header showInfo = true } - if parser := auth.New(header); parser != nil { + if parser := auth.New(header); parser != nil && msg.MessageInfo().Error == nil { details, err := parser(msg.MessageInfo().RFC822Headers, acct.AccountConfig().TrustedAuthRes) if err != nil { hv.Value = err.Error() @@ -115,6 +115,7 @@ func NewMessageViewer(acct *AccountView, err := createSwitcher(acct, switcher, conf, msg) if err != nil { return &MessageViewer{ + acct: acct, err: err, grid: grid, msg: msg, @@ -221,6 +222,10 @@ func createSwitcher(acct *AccountView, switcher *PartSwitcher, switcher.showHeaders = conf.Viewer.ShowHeaders switcher.alwaysShowMime = conf.Viewer.AlwaysShowMime + if msg.MessageInfo().Error != nil { + return fmt.Errorf("could not view message: %w", msg.MessageInfo().Error) + } + if len(msg.BodyStructure().Parts) == 0 { switcher.selected = 0 pv, err := NewPartViewer(acct, conf, msg, msg.BodyStructure(), nil) @@ -383,7 +388,9 @@ func (mv *MessageViewer) Bindings() string { } func (mv *MessageViewer) Close() error { - mv.switcher.Cleanup() + if mv.switcher != nil { + mv.switcher.Cleanup() + } return nil } |