From 4bd4f4664a36f22efad6f6a2cf8861928098e8c4 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Fri, 4 Feb 2022 13:18:52 +0100 Subject: 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 --- commands/compose/postpone.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'commands') 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) -- cgit