summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-09 21:09:52 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-10 17:12:21 +1000
commit6b9390409eb533fe87648be55e9db7d36b1d9ee3 (patch)
tree43e35b86a17dbee8aac245cc93c2645727b61148 /pkg/gui/gui.go
parent8964cedf27cbdb81f59e2400cfc89684d7458605 (diff)
Use an interface for tasks instead of a concrete struct
By using an interface for tasks we can use a fake implementation in tests with extra methods
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 2e63a72d5..d1f000c99 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -472,10 +472,10 @@ func NewGui(
func() error { return gui.State.ContextMgr.Pop() },
func() types.Context { return gui.State.ContextMgr.Current() },
gui.createMenu,
- func(message string, f func(*gocui.Task) error) { gui.helpers.AppStatus.WithWaitingStatus(message, f) },
+ func(message string, f func(gocui.Task) error) { gui.helpers.AppStatus.WithWaitingStatus(message, f) },
func(message string) { gui.helpers.AppStatus.Toast(message) },
func() string { return gui.Views.Confirmation.TextArea.GetContent() },
- func(f func(*gocui.Task)) { gui.c.OnWorker(f) },
+ func(f func(gocui.Task)) { gui.c.OnWorker(f) },
)
guiCommon := &guiCommon{gui: gui, IPopupHandler: gui.PopupHandler}
@@ -780,19 +780,19 @@ func (gui *Gui) loadNewRepo() error {
return nil
}
-func (gui *Gui) showInitialPopups(tasks []func(chan struct{}) error) {
- gui.waitForIntro.Add(len(tasks))
+func (gui *Gui) showInitialPopups(popupTasks []func(chan struct{}) error) {
+ gui.waitForIntro.Add(len(popupTasks))
done := make(chan struct{})
- gui.c.OnWorker(func(gocuiTask *gocui.Task) {
- for _, task := range tasks {
- if err := task(done); err != nil {
+ gui.c.OnWorker(func(task gocui.Task) {
+ for _, popupTask := range popupTasks {
+ if err := popupTask(done); err != nil {
_ = gui.c.Error(err)
}
- gocuiTask.Pause()
+ task.Pause()
<-done
- gocuiTask.Continue()
+ task.Continue()
gui.waitForIntro.Done()
}
})
@@ -833,7 +833,7 @@ func (gui *Gui) onUIThread(f func() error) {
})
}
-func (gui *Gui) onWorker(f func(*gocui.Task)) {
+func (gui *Gui) onWorker(f func(gocui.Task)) {
gui.g.OnWorker(f)
}