From 4d4fc030229ade2c324dc37a3084e41ea9e5b6ed Mon Sep 17 00:00:00 2001 From: genshen Date: Wed, 7 Feb 2024 19:48:12 +0800 Subject: [PATCH] feat(gui): wait and show fyne-based client error message after the client is started after the fyne-based client is started, we call api handles.Wait() to wait error and show error message dialog if there is some error while running (e.g. connection lost or listern port already in used). This commit is similar as PR #12. This is for the fyne-based client, while #12 is for swiftui client. --- client-ui/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client-ui/main.go b/client-ui/main.go index 9605f66..0dbd978 100644 --- a/client-ui/main.go +++ b/client-ui/main.go @@ -99,9 +99,11 @@ func main() { btnStatus := btnStopped var handles extra.TaskHandles + var ignoreWaitErr = true btnStart.OnTapped = func() { if btnStatus == btnRunning { // running can stop btnStatus = btnStopping + ignoreWaitErr = true btnStart.SetText("Stopping") handles.NotifyCloseWrapper() btnStart.SetText("Start") @@ -135,6 +137,17 @@ func main() { } btnStart.SetText("Stop") btnStatus = btnRunning + go func() { + // the `ignoreWaitErr` the same as swiftui. + ignoreWaitErr = false + // wait error and stop the client + if err := handles.Wait(); err != nil && !ignoreWaitErr { + dialog.ShowError(err, w) + } + btnStart.SetText("Start") + btnStatus = btnStopped + ignoreWaitErr = true + }() } }