mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
Remove unused WithLoaderPanel code
This commit is contained in:
@@ -141,13 +141,8 @@ func (self *ConfirmationHelper) getPopupPanelWidth() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *ConfirmationHelper) prepareConfirmationPanel(
|
func (self *ConfirmationHelper) prepareConfirmationPanel(
|
||||||
ctx goContext.Context,
|
|
||||||
opts types.ConfirmOpts,
|
opts types.ConfirmOpts,
|
||||||
) error {
|
) error {
|
||||||
self.c.Views().Confirmation.HasLoader = opts.HasLoader
|
|
||||||
if opts.HasLoader {
|
|
||||||
self.c.GocuiGui().StartTicking(ctx)
|
|
||||||
}
|
|
||||||
self.c.Views().Confirmation.Title = opts.Title
|
self.c.Views().Confirmation.Title = opts.Title
|
||||||
// for now we do not support wrapping in our editor
|
// for now we do not support wrapping in our editor
|
||||||
self.c.Views().Confirmation.Wrap = !opts.Editable
|
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()
|
self.c.Mutexes().PopupMutex.Lock()
|
||||||
defer self.c.Mutexes().PopupMutex.Unlock()
|
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
|
// 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
|
// 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()
|
self.clearConfirmationViewKeyBindings()
|
||||||
|
|
||||||
err := self.prepareConfirmationPanel(
|
err := self.prepareConfirmationPanel(
|
||||||
ctx,
|
|
||||||
types.ConfirmOpts{
|
types.ConfirmOpts{
|
||||||
Title: opts.Title,
|
Title: opts.Title,
|
||||||
Prompt: opts.Prompt,
|
Prompt: opts.Prompt,
|
||||||
HasLoader: opts.HasLoader,
|
|
||||||
FindSuggestionsFunc: opts.FindSuggestionsFunc,
|
FindSuggestionsFunc: opts.FindSuggestionsFunc,
|
||||||
Editable: opts.Editable,
|
Editable: opts.Editable,
|
||||||
Mask: opts.Mask,
|
Mask: opts.Mask,
|
||||||
|
@@ -487,7 +487,6 @@ func NewGui(
|
|||||||
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(message string) { gui.helpers.AppStatus.Toast(message) },
|
||||||
func() string { return gui.Views.Confirmation.TextArea.GetContent() },
|
func() string { return gui.Views.Confirmation.TextArea.GetContent() },
|
||||||
func(f func(gocui.Task)) { gui.c.OnWorker(f) },
|
|
||||||
func() bool { return gui.c.InDemo() },
|
func() bool { return gui.c.InDemo() },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -3,11 +3,9 @@ package popup
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
"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/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/sasha-s/go-deadlock"
|
"github.com/sasha-s/go-deadlock"
|
||||||
@@ -25,7 +23,6 @@ type PopupHandler struct {
|
|||||||
withWaitingStatusFn func(message string, f func(gocui.Task) error)
|
withWaitingStatusFn func(message string, f func(gocui.Task) error)
|
||||||
toastFn func(message string)
|
toastFn func(message string)
|
||||||
getPromptInputFn func() string
|
getPromptInputFn func() string
|
||||||
onWorker func(func(gocui.Task))
|
|
||||||
inDemo func() bool
|
inDemo func() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +38,6 @@ func NewPopupHandler(
|
|||||||
withWaitingStatusFn func(message string, f func(gocui.Task) error),
|
withWaitingStatusFn func(message string, f func(gocui.Task) error),
|
||||||
toastFn func(message string),
|
toastFn func(message string),
|
||||||
getPromptInputFn func() string,
|
getPromptInputFn func() string,
|
||||||
onWorker func(func(gocui.Task)),
|
|
||||||
inDemo func() bool,
|
inDemo func() bool,
|
||||||
) *PopupHandler {
|
) *PopupHandler {
|
||||||
return &PopupHandler{
|
return &PopupHandler{
|
||||||
@@ -55,7 +51,6 @@ func NewPopupHandler(
|
|||||||
withWaitingStatusFn: withWaitingStatusFn,
|
withWaitingStatusFn: withWaitingStatusFn,
|
||||||
toastFn: toastFn,
|
toastFn: toastFn,
|
||||||
getPromptInputFn: getPromptInputFn,
|
getPromptInputFn: getPromptInputFn,
|
||||||
onWorker: onWorker,
|
|
||||||
inDemo: inDemo,
|
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
|
// returns the content that has currently been typed into the prompt. Useful for
|
||||||
// asynchronously updating the suggestions list under the prompt.
|
// asynchronously updating the suggestions list under the prompt.
|
||||||
func (self *PopupHandler) GetPromptInput() string {
|
func (self *PopupHandler) GetPromptInput() string {
|
||||||
|
@@ -134,7 +134,6 @@ type IPopupHandler interface {
|
|||||||
Confirm(opts ConfirmOpts) error
|
Confirm(opts ConfirmOpts) error
|
||||||
// Shows a popup prompting the user for input.
|
// Shows a popup prompting the user for input.
|
||||||
Prompt(opts PromptOpts) error
|
Prompt(opts PromptOpts) error
|
||||||
WithLoaderPanel(message string, f func(gocui.Task) error) error
|
|
||||||
WithWaitingStatus(message string, f func(gocui.Task) error) error
|
WithWaitingStatus(message string, f func(gocui.Task) error) error
|
||||||
Menu(opts CreateMenuOptions) error
|
Menu(opts CreateMenuOptions) error
|
||||||
Toast(message string)
|
Toast(message string)
|
||||||
@@ -166,7 +165,6 @@ type ConfirmOpts struct {
|
|||||||
Prompt string
|
Prompt string
|
||||||
HandleConfirm func() error
|
HandleConfirm func() error
|
||||||
HandleClose func() error
|
HandleClose func() error
|
||||||
HasLoader bool
|
|
||||||
FindSuggestionsFunc func(string) []*Suggestion
|
FindSuggestionsFunc func(string) []*Suggestion
|
||||||
Editable bool
|
Editable bool
|
||||||
Mask bool
|
Mask bool
|
||||||
|
Reference in New Issue
Block a user