summary refs log tree commit diff stats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorKevin Kuehler <keur@ocf.berkeley.edu>2019-06-01 22:15:04 -0700
committerDrew DeVault <sir@cmpwn.com>2019-06-02 10:16:29 -0400
commit753adb90692e4821f8caea1d5d86cd69e312efa7 (patch)
tree79f7563e0ef68264b12244160b3274b678875624 /widgets/msgviewer.go
parent2be985fecb0d76e8fa7cdc46c8de92b6caab9552 (diff)
downloadaerc-753adb90692e4821f8caea1d5d86cd69e312efa7.tar.gz
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>
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index cf360bc..9230ba3 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]