fix some things

This commit is contained in:
Jesse Duffield 2022-11-10 19:27:28 +11:00
parent 52040d1d99
commit 7f38cf2ab2
3 changed files with 11 additions and 11 deletions

View file

@ -21,8 +21,9 @@ func (gui *Gui) renderContainerLogsToMain(container *commands.Container) tasks.T
Func: func(stop, notifyStopped chan struct{}) {
gui.renderContainerLogsToMainAux(container, stop, notifyStopped)
},
Duration: time.Millisecond * 200,
Before: nil,
Duration: time.Millisecond * 200,
// TODO: see why this isn't working (when switching from Top tab to Logs tab in the services panel, the tops tab's content isn't removed)
Before: func(stop chan struct{}) { gui.clearMainView() },
Wrap: gui.Config.UserConfig.Gui.WrapMainPanel,
Autoscroll: true,
})
@ -34,11 +35,7 @@ func (gui *Gui) renderContainerLogsToMainAux(container *commands.Container, stop
notifyStopped <- struct{}{}
}()
ctx, ctxCancel := context.WithCancel(context.Background())
go func() {
<-stop
ctxCancel()
}()
ctx := stopIntoCtx(stop)
mainView := gui.Views.Main

View file

@ -6,6 +6,7 @@ import (
"github.com/go-errors/errors"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazydocker/pkg/tasks"
"github.com/jesseduffield/lazydocker/pkg/utils"
"github.com/samber/lo"
)
@ -63,7 +64,7 @@ var _ ISideListPanel = &SideListPanel[int]{}
type IGui interface {
HandleClick(v *gocui.View, itemCount int, selectedLine *int, handleSelect func() error) error
RenderStringMain(message string)
NewSimpleRenderStringTask(getContent func() string) tasks.TaskFunc
FocusY(selectedLine int, itemCount int, view *gocui.View)
ShouldRefresh(contextKey string) bool
GetMainView() *gocui.View
@ -107,8 +108,7 @@ func (self *SideListPanel[T]) HandleSelect() error {
}
if self.NoItemsMessage != "" {
// TODO: use task for this
self.Gui.RenderStringMain(self.NoItemsMessage)
self.Gui.NewSimpleRenderStringTask(func() string { return self.NoItemsMessage })
}
return nil

View file

@ -35,6 +35,9 @@ func (gui *Gui) NewRenderStringTask(opts RenderStringTaskOpts) tasks.TaskFunc {
Autoscroll: opts.Autoscroll,
Wrap: opts.Wrap,
Func: func(stop chan struct{}) {
// GetStrContent may be a slow function, so we clear the main view first
// so that we're not seeing the previous tab's content appear.
gui.clearMainView()
gui.RenderStringMain(opts.GetStrContent())
},
}
@ -81,7 +84,7 @@ func (gui *Gui) NewTickerTask(opts TickerTaskOpts) tasks.TaskFunc {
gui.Log.Info("exiting ticker task due to notifyStopped channel")
return
case <-stop:
gui.Log.Info("exiting ticker task due to stopped cahnnel")
gui.Log.Info("exiting ticker task due to stopped channel")
return
case <-tickChan.C:
gui.Log.Info("running ticker task again")