diff options
author | Ben Burwell <ben@benburwell.com> | 2019-07-07 22:43:58 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-08 16:06:28 -0400 |
commit | c610c3cd9dd47c400e52c1858e987f5f32a7a45b (patch) | |
tree | 6e521ba706d87ea4a03ce81d57ff84317506f3df /widgets | |
parent | 88c379dcbaaf9fd549cd271817e79fe634b1dd84 (diff) | |
download | aerc-c610c3cd9dd47c400e52c1858e987f5f32a7a45b.tar.gz |
Factor IMAP-specific structs out of UI models
Before, we were using several IMAP-specific concepts to represent information being displayed in the UI. Factor these structures out of the IMAP package to make it easier for other backends to provide the required information.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/msglist.go | 3 | ||||
-rw-r--r-- | widgets/msgviewer.go | 17 | ||||
-rw-r--r-- | widgets/providesmessage.go | 6 |
3 files changed, 11 insertions, 15 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go index 7051478..8968653 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -4,7 +4,6 @@ import ( "fmt" "log" - "github.com/emersion/go-imap" "github.com/gdamore/tcell" "github.com/mattn/go-runewidth" @@ -86,7 +85,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) { // unread message seen := false for _, flag := range msg.Flags { - if flag == imap.SeenFlag { + if flag == models.SeenFlag { seen = true } } diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index 6a645f9..f6bef2d 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 @@ -334,7 +333,7 @@ type PartViewer struct { 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 ( @@ -365,11 +364,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) diff --git a/widgets/providesmessage.go b/widgets/providesmessage.go index d8b1e77..a1cfaa8 100644 --- a/widgets/providesmessage.go +++ b/widgets/providesmessage.go @@ -1,8 +1,6 @@ package widgets import ( - "github.com/emersion/go-imap" - "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/lib/ui" "git.sr.ht/~sircmpwn/aerc/models" @@ -10,8 +8,8 @@ import ( type PartInfo struct { Index []int - Msg *types.MessageInfo - Part *imap.BodyStructure + Msg *models.MessageInfo + Part *models.BodyStructure Store *lib.MessageStore } |