Skip to content

Commit

Permalink
merge(gui): Merge pull request #21 from genshen/feature-client-ui-wai…
Browse files Browse the repository at this point in the history
…t-error

feat(gui): wait and show fyne-based client error message after the client is started
  • Loading branch information
genshen committed Feb 7, 2024
2 parents 9e0c246 + 4d4fc03 commit a8cb334
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 a8cb334

Please sign in to comment.