aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-02-04 13:18:52 +0100
committerRobin Jarry <robin@jarry.cc>2022-02-06 17:06:20 +0100
commit4bd4f4664a36f22efad6f6a2cf8861928098e8c4 (patch)
tree90df58e35bfb818a35be507ab362ac2c540b7d72
parentdfb7240d484cfd66fb96f342f27b974950a739da (diff)
downloadaerc-4bd4f4664a36f22efad6f6a2cf8861928098e8c4.tar.gz
postpone: re-open review mode on error
re-opens the review UI when the postpone operation fails. Before, the composer would close, even on error, and we would lose the email draft. Now, the user can decide on how to proceed when postponing fails. References: https://lists.sr.ht/~rjarry/aerc-devel/patches/28824 Signed-off-by: Koni Marti <koni.marti@gmail.com>
-rw-r--r--commands/compose/postpone.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go
index 03a8608e..f918b527 100644
--- a/commands/compose/postpone.go
+++ b/commands/compose/postpone.go
@@ -33,6 +33,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
}
composer, _ := aerc.SelectedTab().(*widgets.Composer)
config := composer.Config()
+ tabName := aerc.TabNames()[aerc.SelectedTabIndex()]
if config.Postpone == "" {
return errors.New("No Postpone location configured")
@@ -67,12 +68,17 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
return
}
+ handleErr := func(err error) {
+ aerc.PushError(err.Error())
+ aerc.Logger().Println("Postponing failed:", err)
+ aerc.NewTab(composer, tabName)
+ }
+
aerc.RemoveTab(composer)
ctr := datacounter.NewWriterCounter(ioutil.Discard)
err = composer.WriteMessage(header, ctr)
if err != nil {
- aerc.PushError(errors.Wrap(err, "WriteMessage").Error())
- composer.Close()
+ handleErr(errors.Wrap(err, "WriteMessage"))
return
}
nbytes := int(ctr.Count())
@@ -90,9 +96,8 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error {
r.Close()
composer.Close()
case *types.Error:
- aerc.PushError(msg.Error.Error())
r.Close()
- composer.Close()
+ handleErr(msg.Error)
}
})
composer.WriteMessage(header, w)