open: simplify code

There is no need for convoluted channels and other async fanciness.
Expose a single XDGOpen static function that runs a command and returns
an error if any.

Caller is responsible of running this in an async goroutine if needed.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
Robin Jarry 2022-09-30 10:52:49 +02:00
parent 8e53d33061
commit 92ba132d70
3 changed files with 19 additions and 73 deletions
commands/msg

View file

@ -183,9 +183,11 @@ func unsubscribeHTTP(aerc *widgets.Aerc, u *url.URL) error {
aerc.CloseDialog()
switch option {
case "Yes":
if err := lib.NewXDGOpen(u.String()).Start(); err != nil {
aerc.PushError("Unsubscribe:" + err.Error())
}
go func() {
if err := lib.XDGOpen(u.String()); err != nil {
aerc.PushError("Unsubscribe:" + err.Error())
}
}()
default:
aerc.PushError("Unsubscribe: link will not be opened")
}