diff options
-rw-r--r-- | commands/account/view-message.go | 6 | ||||
-rw-r--r-- | widgets/msglist.go | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/commands/account/view-message.go b/commands/account/view-message.go index edafd09..ea6addc 100644 --- a/commands/account/view-message.go +++ b/commands/account/view-message.go @@ -17,8 +17,14 @@ func ViewMessage(aerc *widgets.Aerc, args []string) error { return errors.New("Usage: view-message") } acct := aerc.SelectedAccount() + if acct.Messages().Empty() { + return nil + } store := acct.Messages().Store() msg := acct.Messages().Selected() + if msg == nil { + return nil + } viewer := widgets.NewMessageViewer(aerc.Config(), store, msg) aerc.NewTab(viewer, runewidth.Truncate( msg.Envelope.Subject, 32, "…")) diff --git a/widgets/msglist.go b/widgets/msglist.go index 1624e64..ea9b245 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -138,6 +138,10 @@ func (ml *MessageList) Store() *lib.MessageStore { return ml.store } +func (ml *MessageList) Empty() bool { + return ml.store == nil || len(ml.store.Uids) == 0 +} + func (ml *MessageList) Selected() *types.MessageInfo { return ml.store.Messages[ml.store.Uids[len(ml.store.Uids)-ml.selected-1]] } |