aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/pipe.go7
-rw-r--r--commands/msgview/open.go3
-rw-r--r--commands/msgview/save.go11
-rw-r--r--widgets/msgviewer.go4
4 files changed, 14 insertions, 11 deletions
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index b33254d7..b354341c 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -182,12 +182,15 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
}
}()
} else if pipePart {
+ mv, ok := provider.(*widgets.MessageViewer)
+ if !ok {
+ return fmt.Errorf("can only pipe message part from a message view")
+ }
p := provider.SelectedMessagePart()
if p == nil {
return fmt.Errorf("could not fetch message part")
}
- store := provider.Store()
- store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
+ mv.MessageView().FetchBodyPart(p.Index, func(reader io.Reader) {
if background {
doExec(reader)
} else {
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index 3d62fe22..c2761729 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -49,8 +49,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
return nil
}
- store := mv.Store()
- store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
+ mv.MessageView().FetchBodyPart(p.Index, func(reader io.Reader) {
extension := ""
// try to determine the correct extension based on mimetype
if part, err := p.Msg.BodyStructure.PartAtIndex(p.Index); err == nil {
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 2a5eadf9..8aedd428 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -13,7 +13,6 @@ import (
"github.com/mitchellh/go-homedir"
"git.sr.ht/~rjarry/aerc/commands"
- "git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -105,8 +104,6 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
return fmt.Errorf("SelectedTab is not a MessageViewer")
}
- store := mv.Store()
-
if params.attachments {
parts := mv.AttachmentParts()
if len(parts) == 0 {
@@ -114,7 +111,7 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
}
params.trailingSlash = true
for _, pi := range parts {
- if err := savePart(pi, path, store, aerc, &params); err != nil {
+ if err := savePart(pi, path, mv, aerc, &params); err != nil {
return err
}
}
@@ -122,13 +119,13 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
}
pi := mv.SelectedMessagePart()
- return savePart(pi, path, store, aerc, &params)
+ return savePart(pi, path, mv, aerc, &params)
}
func savePart(
pi *widgets.PartInfo,
path string,
- store *lib.MessageStore,
+ mv *widgets.MessageViewer,
aerc *widgets.Aerc,
params *saveParams,
) error {
@@ -151,7 +148,7 @@ func savePart(
}
ch := make(chan error, 1)
- store.FetchBodyPart(pi.Msg.Uid, pi.Index, func(reader io.Reader) {
+ mv.MessageView().FetchBodyPart(pi.Index, func(reader io.Reader) {
f, err := os.Create(path)
if err != nil {
ch <- err
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index b41b57c0..0e6af5b5 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -290,6 +290,10 @@ func (mv *MessageViewer) SelectedAccount() *AccountView {
return mv.acct
}
+func (mv *MessageViewer) MessageView() lib.MessageView {
+ return mv.msg
+}
+
func (mv *MessageViewer) SelectedMessage() (*models.MessageInfo, error) {
if mv.msg == nil {
return nil, errors.New("no message selected")