diff options
author | Ben Burwell <ben@benburwell.com> | 2019-07-04 22:34:52 -0400 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2019-07-04 22:37:29 -0400 |
commit | b46b497f99d7f4dcba8936ce0ebfe8cf982cec1f (patch) | |
tree | b9212d4b196706d3c0e2d93b8dfd8cc39cbacf3b /widgets/msgviewer.go | |
parent | 6574dedd8a4afdaedd3677283955a866214bd99a (diff) |
Factor UI models out of the worker message packagemdps1
Before, the information needed to display different parts of the UI was
tightly coupled to the specific messages being sent back and forth to
the backend worker. Separating out a models package allows us to be more
specific about exactly what a backend is able to and required to provide
for the UI.
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r-- | widgets/msgviewer.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 49b4dd4..47b9dff 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -9,7 +9,6 @@ import ( "strings" "github.com/danwakefield/fnmatch" - "github.com/emersion/go-imap" "github.com/emersion/go-message" _ "github.com/emersion/go-message/charset" "github.com/emersion/go-message/mail" @@ -66,12 +65,12 @@ func NewMessageViewer(acct *AccountView, conf *config.AercConfig, headers.AddChild( &HeaderView{ Name: "From", - Value: lib.FormatAddresses(msg.Envelope.From), + Value: models.FormatAddresses(msg.Envelope.From), }).At(0, 0) headers.AddChild( &HeaderView{ Name: "To", - Value: lib.FormatAddresses(msg.Envelope.To), + Value: models.FormatAddresses(msg.Envelope.To), }).At(0, 1) headers.AddChild( &HeaderView{ @@ -112,7 +111,7 @@ handle_error: } func enumerateParts(conf *config.AercConfig, store *lib.MessageStore, - msg *models.MessageInfo, body *imap.BodyStructure, + msg *models.MessageInfo, body *models.BodyStructure, showHeaders bool, index []int) ([]*PartViewer, error) { var parts []*PartViewer @@ -324,7 +323,7 @@ type PartViewer struct { msg *models.MessageInfo pager *exec.Cmd pagerin io.WriteCloser - part *imap.BodyStructure + part *models.BodyStructure showHeaders bool sink io.WriteCloser source io.Reader @@ -335,13 +334,13 @@ type PartViewer struct { type PartInfo struct { Index []int Msg *models.MessageInfo - Part *imap.BodyStructure + Part *models.BodyStructure Store *lib.MessageStore } func NewPartViewer(conf *config.AercConfig, store *lib.MessageStore, msg *models.MessageInfo, - part *imap.BodyStructure, showHeaders bool, + part *models.BodyStructure, showHeaders bool, index []int) (*PartViewer, error) { var ( @@ -372,11 +371,11 @@ func NewPartViewer(conf *config.AercConfig, case "subject": header = msg.Envelope.Subject case "from": - header = lib.FormatAddresses(msg.Envelope.From) + header = models.FormatAddresses(msg.Envelope.From) case "to": - header = lib.FormatAddresses(msg.Envelope.To) + header = models.FormatAddresses(msg.Envelope.To) case "cc": - header = lib.FormatAddresses(msg.Envelope.Cc) + header = models.FormatAddresses(msg.Envelope.Cc) } if f.Regex.Match([]byte(header)) { filter = exec.Command("sh", "-c", f.Command) |