summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-07-11 20:23:42 +0200
committerRobin Jarry <robin@jarry.cc>2022-07-14 23:15:13 +0200
commit76b39311dc0ea6211a79d738b4fd8d335ade53fd (patch)
treeb30960e55d5d82938408534c66aaed32368f8963
parente200cd56bf22ec48d1b0441be2355dc6dcb35cd4 (diff)
downloadaerc-76b39311dc0ea6211a79d738b4fd8d335ade53fd.zip
send: enter no-quit mode until message is sent
Protect the sending of a message by entering the no-quit mode. This prevents aerc from exiting with the :quit command until the operation is done or the exit is forced. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/compose/send.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 574e872..dd3a8d3 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -15,6 +15,7 @@ import (
"github.com/google/shlex"
"github.com/pkg/errors"
+ "git.sr.ht/~rjarry/aerc/commands/mode"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
@@ -96,6 +97,9 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
aerc.RemoveTab(composer)
aerc.PushStatus("Sending...", 10*time.Second)
+ // enter no-quit mode
+ mode.NoQuit()
+
var copyBuf bytes.Buffer // for the Sent folder content if CopyTo is set
failCh := make(chan error)
@@ -136,6 +140,9 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
go func() {
defer logging.PanicHandler()
+ // leave no-quit mode
+ defer mode.NoQuitDone()
+
err = <-failCh
if err != nil {
aerc.PushError(strings.ReplaceAll(err.Error(), "\n", " "))