aerc/commands/account/view.go
Kevin Kuehler 753adb9069 widget: Add ProvidesMessage interface
Consists of 3 functions
* Store: Access to MessageStore type
* SelectedAccount: Access to Account widget that the target widget
belongs to
* SelectedMessage: Current message (selected in msglist or the one we
are viewing)

Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-06-02 10:16:29 -04:00

30 lines
596 B
Go

package account
import (
"errors"
"git.sr.ht/~sircmpwn/aerc/widgets"
)
func init() {
register("view", ViewMessage)
register("view-message", ViewMessage)
}
func ViewMessage(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
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(acct, aerc.Config(), store, msg)
aerc.NewTab(viewer, msg.Envelope.Subject)
return nil
}