diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-10 13:05:49 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-10 17:12:34 +1000 |
commit | c05a1ae71197d95038add5aef3a16dccc3c851d4 (patch) | |
tree | 0dbdf0cfb7c78c65b9351db11e7613833190bbce /pkg/gui/gui.go | |
parent | a0154dc5257e6b3f5c6f8bb25836b3aecc671875 (diff) |
Fix flakey misc/initial_open test
I've simplifiied the code because it was too complex for the current requirements, and this fixed the misc/initial_open
test which was occasionally failing due to a race condition around busy tasks
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index d1f000c99..1057a85bf 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -780,37 +780,23 @@ func (gui *Gui) loadNewRepo() error { return nil } -func (gui *Gui) showInitialPopups(popupTasks []func(chan struct{}) error) { - gui.waitForIntro.Add(len(popupTasks)) - done := make(chan struct{}) - - gui.c.OnWorker(func(task gocui.Task) { - for _, popupTask := range popupTasks { - if err := popupTask(done); err != nil { - _ = gui.c.Error(err) - } +func (gui *Gui) showIntroPopupMessage() { + gui.waitForIntro.Add(1) - task.Pause() - <-done - task.Continue() + gui.c.OnUIThread(func() error { + onConfirm := func() error { + gui.c.GetAppState().StartupPopupVersion = StartupPopupVersion + err := gui.c.SaveAppState() gui.waitForIntro.Done() + return err } - }) -} - -func (gui *Gui) showIntroPopupMessage(done chan struct{}) error { - onConfirm := func() error { - gui.c.GetAppState().StartupPopupVersion = StartupPopupVersion - err := gui.c.SaveAppState() - done <- struct{}{} - return err - } - return gui.c.Confirm(types.ConfirmOpts{ - Title: "", - Prompt: gui.c.Tr.IntroPopupMessage, - HandleConfirm: onConfirm, - HandleClose: onConfirm, + return gui.c.Confirm(types.ConfirmOpts{ + Title: "", + Prompt: gui.c.Tr.IntroPopupMessage, + HandleConfirm: onConfirm, + HandleClose: onConfirm, + }) }) } |