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>
This commit is contained in:
parent
dfb7240d48
commit
4bd4f4664a
1 changed files with 9 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue