recall: confirm deleting message when not sent
Ask for user confirmation when a recalled message is deleted after the composer is closed but the message has not been sent yet. The message will only be deleted automatically when the message is sent. This might prevent data loss since the recalled message is currently deleted either way. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
99b74dbcc9
commit
4335eeceb3
1 changed files with 34 additions and 9 deletions
|
@ -2,6 +2,7 @@ package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/emersion/go-message"
|
"github.com/emersion/go-message"
|
||||||
_ "github.com/emersion/go-message/charset"
|
_ "github.com/emersion/go-message/charset"
|
||||||
|
@ -99,15 +100,39 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
worker.PostAction(&types.DeleteMessages{
|
deleteMessage := func() {
|
||||||
Uids: uids,
|
worker.PostAction(&types.DeleteMessages{
|
||||||
}, func(msg types.WorkerMessage) {
|
Uids: uids,
|
||||||
switch msg := msg.(type) {
|
}, func(msg types.WorkerMessage) {
|
||||||
case *types.Error:
|
switch msg := msg.(type) {
|
||||||
aerc.PushError(msg.Error.Error())
|
case *types.Done:
|
||||||
composer.Close()
|
aerc.PushStatus("Recalled message deleted", 10*time.Second)
|
||||||
}
|
case *types.Error:
|
||||||
})
|
aerc.PushError(msg.Error.Error())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if composer.Sent() {
|
||||||
|
deleteMessage()
|
||||||
|
} else {
|
||||||
|
confirm := widgets.NewSelectorDialog(
|
||||||
|
"Delete recalled message?",
|
||||||
|
"If you proceed, the recalled message will be deleted.",
|
||||||
|
[]string{"Cancel", "Proceed"}, 0, aerc.SelectedAccountUiConfig(),
|
||||||
|
func(option string, err error) {
|
||||||
|
aerc.CloseDialog()
|
||||||
|
switch option {
|
||||||
|
case "Proceed":
|
||||||
|
deleteMessage()
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return
|
||||||
|
},
|
||||||
|
)
|
||||||
|
aerc.AddDialog(confirm)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue