summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context/remotes_context.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/context/remotes_context.go')
-rw-r--r--pkg/gui/context/remotes_context.go37
1 files changed, 18 insertions, 19 deletions
diff --git a/pkg/gui/context/remotes_context.go b/pkg/gui/context/remotes_context.go
index 0f11908dd..d1082ab52 100644
--- a/pkg/gui/context/remotes_context.go
+++ b/pkg/gui/context/remotes_context.go
@@ -1,8 +1,8 @@
package context
import (
- "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@@ -11,35 +11,28 @@ type RemotesContext struct {
*ListContextTrait
}
-var _ types.IListContext = (*RemotesContext)(nil)
-
-func NewRemotesContext(
- getModel func() []*models.Remote,
- view *gocui.View,
- getDisplayStrings func(startIdx int, length int) [][]string,
+var (
+ _ types.IListContext = (*RemotesContext)(nil)
+ _ types.DiffableContext = (*RemotesContext)(nil)
+)
- onFocus func(types.OnFocusOpts) error,
- onRenderToMain func() error,
- onFocusLost func(opts types.OnFocusLostOpts) error,
+func NewRemotesContext(c *ContextCommon) *RemotesContext {
+ viewModel := NewBasicViewModel(func() []*models.Remote { return c.Model().Remotes })
- c *types.HelperCommon,
-) *RemotesContext {
- viewModel := NewBasicViewModel(getModel)
+ getDisplayStrings := func(startIdx int, length int) [][]string {
+ return presentation.GetRemoteListDisplayStrings(c.Model().Remotes, c.Modes().Diffing.Ref)
+ }
return &RemotesContext{
BasicViewModel: viewModel,
ListContextTrait: &ListContextTrait{
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
- View: view,
+ View: c.Views().Remotes,
WindowName: "branches",
Key: REMOTES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT,
Focusable: true,
- }), ContextCallbackOpts{
- OnFocus: onFocus,
- OnFocusLost: onFocusLost,
- OnRenderToMain: onRenderToMain,
- }),
+ })),
list: viewModel,
getDisplayStrings: getDisplayStrings,
c: c,
@@ -55,3 +48,9 @@ func (self *RemotesContext) GetSelectedItemId() string {
return item.ID()
}
+
+func (self *RemotesContext) GetDiffTerminals() []string {
+ itemId := self.GetSelectedItemId()
+
+ return []string{itemId}
+}