diff options
Diffstat (limited to 'pkg/gui/context/stash_context.go')
-rw-r--r-- | pkg/gui/context/stash_context.go | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/pkg/gui/context/stash_context.go b/pkg/gui/context/stash_context.go index d538fadf1..e2af64d10 100644 --- a/pkg/gui/context/stash_context.go +++ b/pkg/gui/context/stash_context.go @@ -3,12 +3,11 @@ package context import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/gui/context/traits" "github.com/jesseduffield/lazygit/pkg/gui/types" ) type StashContext struct { - *StashViewModel + *BasicViewModel[*models.StashEntry] *ListContextTrait } @@ -25,10 +24,10 @@ func NewStashContext( c *types.HelperCommon, ) *StashContext { - viewModel := NewStashViewModel(getModel) + viewModel := NewBasicViewModel(getModel) return &StashContext{ - StashViewModel: viewModel, + BasicViewModel: viewModel, ListContextTrait: &ListContextTrait{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ ViewName: "stash", @@ -71,30 +70,3 @@ func (self *StashContext) GetSelectedRefName() string { return item.RefName() } - -type StashViewModel struct { - *traits.ListCursor - getModel func() []*models.StashEntry -} - -func NewStashViewModel(getModel func() []*models.StashEntry) *StashViewModel { - self := &StashViewModel{ - getModel: getModel, - } - - self.ListCursor = traits.NewListCursor(self) - - return self -} - -func (self *StashViewModel) GetItemsLength() int { - return len(self.getModel()) -} - -func (self *StashViewModel) GetSelected() *models.StashEntry { - if self.GetItemsLength() == 0 { - return nil - } - - return self.getModel()[self.GetSelectedLineIdx()] -} |