diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-15 16:36:39 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-15 18:01:43 +1000 |
commit | d9fa02c53bb9b401f1b5ca07e8ed239862052a42 (patch) | |
tree | 9ce89793ba22ffc190ab6133365035dda4ec1ade /pkg/gui/updates.go | |
parent | c44ee71ad4ca44a407613c1e91f7d720acfa84f6 (diff) |
clean up interface for popup panels
Diffstat (limited to 'pkg/gui/updates.go')
-rw-r--r-- | pkg/gui/updates.go | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/pkg/gui/updates.go b/pkg/gui/updates.go index b44c5d5e4..97ef123fd 100644 --- a/pkg/gui/updates.go +++ b/pkg/gui/updates.go @@ -3,13 +3,18 @@ package gui import "github.com/jesseduffield/gocui" func (gui *Gui) showUpdatePrompt(newVersion string) error { - title := "New version available!" - message := "Download latest version? (enter/esc)" currentView := gui.g.CurrentView() - return gui.createConfirmationPanel(gui.g, currentView, true, title, message, func(g *gocui.Gui, v *gocui.View) error { - gui.startUpdating(newVersion) - return nil - }, nil) + + return gui.createConfirmationPanel(createConfirmationPanelOpts{ + returnToView: currentView, + returnFocusOnClose: true, + title: "New version available!", + prompt: "Download latest version? (enter/esc)", + handleConfirm: func() error { + gui.startUpdating(newVersion) + return nil + }, + }) } func (gui *Gui) onUserUpdateCheckFinish(newVersion string, err error) error { @@ -47,7 +52,7 @@ func (gui *Gui) startUpdating(newVersion string) { func (gui *Gui) onUpdateFinish(err error) error { gui.State.Updating = false gui.statusManager.removeStatus("updating") - gui.renderString(gui.g, "appStatus", "") + gui.renderString("appStatus", "") if err != nil { return gui.createErrorPanel("Update failed: " + err.Error()) } @@ -55,9 +60,13 @@ func (gui *Gui) onUpdateFinish(err error) error { } func (gui *Gui) createUpdateQuitConfirmation(g *gocui.Gui, v *gocui.View) error { - title := "Currently Updating" - message := "An update is in progress. Are you sure you want to quit?" - return gui.createConfirmationPanel(gui.g, v, true, title, message, func(g *gocui.Gui, v *gocui.View) error { - return gocui.ErrQuit - }, nil) + return gui.createConfirmationPanel(createConfirmationPanelOpts{ + returnToView: v, + returnFocusOnClose: true, + title: "Currently Updating", + prompt: "An update is in progress. Are you sure you want to quit?", + handleConfirm: func() error { + return gocui.ErrQuit + }, + }) } |