diff options
Diffstat (limited to 'pkg/gui/context/remotes_context.go')
-rw-r--r-- | pkg/gui/context/remotes_context.go | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/pkg/gui/context/remotes_context.go b/pkg/gui/context/remotes_context.go index 2b6afdeb5..9cb0b6054 100644 --- a/pkg/gui/context/remotes_context.go +++ b/pkg/gui/context/remotes_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 RemotesContext struct { - *RemotesViewModel + *BasicViewModel[*models.Remote] *ListContextTrait } @@ -25,10 +24,10 @@ func NewRemotesContext( c *types.HelperCommon, ) *RemotesContext { - viewModel := NewRemotesViewModel(getModel) + viewModel := NewBasicViewModel(getModel) return &RemotesContext{ - RemotesViewModel: viewModel, + BasicViewModel: viewModel, ListContextTrait: &ListContextTrait{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ ViewName: "branches", @@ -57,30 +56,3 @@ func (self *RemotesContext) GetSelectedItemId() string { return item.ID() } - -type RemotesViewModel struct { - *traits.ListCursor - getModel func() []*models.Remote -} - -func NewRemotesViewModel(getModel func() []*models.Remote) *RemotesViewModel { - self := &RemotesViewModel{ - getModel: getModel, - } - - self.ListCursor = traits.NewListCursor(self) - - return self -} - -func (self *RemotesViewModel) GetItemsLength() int { - return len(self.getModel()) -} - -func (self *RemotesViewModel) GetSelected() *models.Remote { - if self.GetItemsLength() == 0 { - return nil - } - - return self.getModel()[self.GetSelectedLineIdx()] -} |