From 753adb90692e4821f8caea1d5d86cd69e312efa7 Mon Sep 17 00:00:00 2001 From: Kevin Kuehler Date: Sat, 1 Jun 2019 22:15:04 -0700 Subject: 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 --- widgets/msgviewer.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'widgets/msgviewer.go') diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index cf360bca..9230ba3a 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -24,6 +24,7 @@ import ( type MessageViewer struct { ui.Invalidatable + acct *AccountView conf *config.AercConfig err error grid *ui.Grid @@ -55,7 +56,7 @@ func formatAddresses(addrs []*imap.Address) string { return val.String() } -func NewMessageViewer(conf *config.AercConfig, +func NewMessageViewer(acct *AccountView, conf *config.AercConfig, store *lib.MessageStore, msg *types.MessageInfo) *MessageViewer { grid := ui.NewGrid().Rows([]ui.GridSpec{ @@ -124,6 +125,7 @@ func NewMessageViewer(conf *config.AercConfig, grid.AddChild(switcher).At(1, 0) return &MessageViewer{ + acct: acct, grid: grid, msg: msg, store: store, @@ -185,6 +187,18 @@ func (mv *MessageViewer) OnInvalidate(fn func(d ui.Drawable)) { }) } +func (mv *MessageViewer) Store() *lib.MessageStore { + return mv.store +} + +func (mv *MessageViewer) SelectedAccount() *AccountView { + return mv.acct +} + +func (mv *MessageViewer) SelectedMessage() *types.MessageInfo { + return mv.msg +} + func (mv *MessageViewer) CurrentPart() *PartInfo { switcher := mv.switcher part := switcher.parts[switcher.selected] -- cgit