summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-08-29 13:04:29 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-09-20 13:30:49 +0200
commit864a9ada57f2fd5b6d372ba5fc127dd87d53436e (patch)
tree930dc6a305928b08b8ff4137be6aac10e000faee
parentf3e9d50d945d7ea2bc905d1d1c6006ec93f95305 (diff)
Remove unused WithLoaderPanel code
-rw-r--r--pkg/gui/controllers/helpers/confirmation_helper.go9
-rw-r--r--pkg/gui/gui.go1
-rw-r--r--pkg/gui/popup/popup_handler.go46
-rw-r--r--pkg/gui/types/common.go2
4 files changed, 1 insertions, 57 deletions
diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go
index 7d4ca1464..62beaacda 100644
--- a/pkg/gui/controllers/helpers/confirmation_helper.go
+++ b/pkg/gui/controllers/helpers/confirmation_helper.go
@@ -141,13 +141,8 @@ func (self *ConfirmationHelper) getPopupPanelWidth() int {
}
func (self *ConfirmationHelper) prepareConfirmationPanel(
- ctx goContext.Context,
opts types.ConfirmOpts,
) error {
- self.c.Views().Confirmation.HasLoader = opts.HasLoader
- if opts.HasLoader {
- self.c.GocuiGui().StartTicking(ctx)
- }
self.c.Views().Confirmation.Title = opts.Title
// for now we do not support wrapping in our editor
self.c.Views().Confirmation.Wrap = !opts.Editable
@@ -181,7 +176,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
self.c.Mutexes().PopupMutex.Lock()
defer self.c.Mutexes().PopupMutex.Unlock()
- ctx, cancel := goContext.WithCancel(ctx)
+ _, cancel := goContext.WithCancel(ctx)
// we don't allow interruptions of non-loader popups in case we get stuck somehow
// e.g. a credentials popup never gets its required user input so a process hangs
@@ -198,11 +193,9 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
self.clearConfirmationViewKeyBindings()
err := self.prepareConfirmationPanel(
- ctx,
types.ConfirmOpts{
Title: opts.Title,
Prompt: opts.Prompt,
- HasLoader: opts.HasLoader,
FindSuggestionsFunc: opts.FindSuggestionsFunc,
Editable: opts.Editable,
Mask: opts.Mask,
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 4be909dc8..1f76e281c 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -487,7 +487,6 @@ func NewGui(
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() bool { return gui.c.InDemo() },
)
diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go
index eab468e46..cd34bc20e 100644
--- a/pkg/gui/popup/popup_handler.go
+++ b/pkg/gui/popup/popup_handler.go
@@ -3,11 +3,9 @@ package popup
import (
"context"
"strings"
- "time"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/common"
- gctx "github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/sasha-s/go-deadlock"
@@ -25,7 +23,6 @@ type PopupHandler struct {
withWaitingStatusFn func(message string, f func(gocui.Task) error)
toastFn func(message string)
getPromptInputFn func() string
- onWorker func(func(gocui.Task))
inDemo func() bool
}
@@ -41,7 +38,6 @@ func NewPopupHandler(
withWaitingStatusFn func(message string, f func(gocui.Task) error),
toastFn func(message string),
getPromptInputFn func() string,
- onWorker func(func(gocui.Task)),
inDemo func() bool,
) *PopupHandler {
return &PopupHandler{
@@ -55,7 +51,6 @@ func NewPopupHandler(
withWaitingStatusFn: withWaitingStatusFn,
toastFn: toastFn,
getPromptInputFn: getPromptInputFn,
- onWorker: onWorker,
inDemo: inDemo,
}
}
@@ -128,47 +123,6 @@ func (self *PopupHandler) Prompt(opts types.PromptOpts) error {
})
}
-func (self *PopupHandler) WithLoaderPanel(message string, f func(gocui.Task) error) error {
- index := 0
- self.Lock()
- self.index++
- index = self.index
- self.Unlock()
-
- ctx, cancel := context.WithCancel(context.Background())
-
- err := self.createPopupPanelFn(ctx, types.CreatePopupPanelOpts{
- Prompt: message,
- HasLoader: true,
- })
- if err != nil {
- self.Log.Error(err)
- cancel()
- return nil
- }
-
- self.onWorker(func(task gocui.Task) {
- // emulating a delay due to network latency
- if self.inDemo() {
- time.Sleep(500 * time.Millisecond)
- }
-
- if err := f(task); err != nil {
- self.Log.Error(err)
- }
-
- cancel()
-
- self.Lock()
- if index == self.index && self.currentContextFn().GetKey() == gctx.CONFIRMATION_CONTEXT_KEY {
- _ = self.popContextFn()
- }
- self.Unlock()
- })
-
- return nil
-}
-
// returns the content that has currently been typed into the prompt. Useful for
// asynchronously updating the suggestions list under the prompt.
func (self *PopupHandler) GetPromptInput() string {
diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go
index 5f1363f03..80d960eab 100644
--- a/pkg/gui/types/common.go
+++ b/pkg/gui/types/common.go
@@ -134,7 +134,6 @@ type IPopupHandler interface {
Confirm(opts ConfirmOpts) error
// Shows a popup prompting the user for input.
Prompt(opts PromptOpts) error
- WithLoaderPanel(message string, f func(gocui.Task) error) error
WithWaitingStatus(message string, f func(gocui.Task) error) error
Menu(opts CreateMenuOptions) error
Toast(message string)
@@ -166,7 +165,6 @@ type ConfirmOpts struct {
Prompt string
HandleConfirm func() error
HandleClose func() error
- HasLoader bool
FindSuggestionsFunc func(string) []*Suggestion
Editable bool
Mask bool