diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-04-14 20:06:25 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-04-18 10:10:30 +0200 |
commit | 1869fda8006731ecc15b748028ce1b9742a4c756 (patch) | |
tree | f4f3793d6bcd55d14db39c6919c943b30a0848a6 /pkg/gui/controllers/helpers/app_status_helper.go | |
parent | 5396a706611220077d32d01058d5e4b025eab0de (diff) |
Make OnWorker callback return an error
This lets us get rid of a few more calls to Error(), and it simplifies things
for clients of OnWorker: they can simply return an error from their callback
like we do everywhere else.
Diffstat (limited to 'pkg/gui/controllers/helpers/app_status_helper.go')
-rw-r--r-- | pkg/gui/controllers/helpers/app_status_helper.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/pkg/gui/controllers/helpers/app_status_helper.go b/pkg/gui/controllers/helpers/app_status_helper.go index 31bfcca3a..b0d1b3818 100644 --- a/pkg/gui/controllers/helpers/app_status_helper.go +++ b/pkg/gui/controllers/helpers/app_status_helper.go @@ -59,15 +59,10 @@ func (self appStatusHelperTask) Continue() { // withWaitingStatus wraps a function and shows a waiting status while the function is still executing func (self *AppStatusHelper) WithWaitingStatus(message string, f func(gocui.Task) error) { - self.c.OnWorker(func(task gocui.Task) { - err := self.statusMgr().WithWaitingStatus(message, self.renderAppStatus, func(waitingStatusHandle *status.WaitingStatusHandle) error { + self.c.OnWorker(func(task gocui.Task) error { + return self.statusMgr().WithWaitingStatus(message, self.renderAppStatus, func(waitingStatusHandle *status.WaitingStatusHandle) error { return f(appStatusHelperTask{task, waitingStatusHandle}) }) - if err != nil { - self.c.OnUIThread(func() error { - return err - }) - } }) } @@ -91,7 +86,7 @@ func (self *AppStatusHelper) GetStatusString() string { } func (self *AppStatusHelper) renderAppStatus() { - self.c.OnWorker(func(_ gocui.Task) { + self.c.OnWorker(func(_ gocui.Task) error { ticker := time.NewTicker(time.Millisecond * time.Duration(self.c.UserConfig.Gui.Spinner.Rate)) defer ticker.Stop() for range ticker.C { @@ -103,9 +98,10 @@ func (self *AppStatusHelper) renderAppStatus() { }) if appStatus == "" { - return + break } } + return nil }) } |