1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

Remove unused WithLoaderPanel code

This commit is contained in:
Stefan Haller
2023-08-29 13:04:29 +02:00
parent f3e9d50d94
commit 864a9ada57
4 changed files with 1 additions and 57 deletions

View File

@@ -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 {