Skip to content

Commit

Permalink
feat(gui): wait and show fyne-based client error message after the cl…
Browse files Browse the repository at this point in the history
…ient 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.
  • Loading branch information
genshen committed Feb 7, 2024
1 parent 9e0c246 commit 4d4fc03
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client-ui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}()
}
}

Expand Down

0 comments on commit 4d4fc03

Please sign in to comment.