Skip to content

Commit

Permalink
fix: lazy load git tui bubbles
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Feb 18, 2022
1 parent 61a8eb1 commit 352b06d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/tui/bubbles/git/log/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (b *Bubble) GotoTop() {
}

func (b *Bubble) Init() tea.Cmd {
return b.reset()
return nil
}

func (b *Bubble) SetSize(width, height int) {
Expand Down
8 changes: 6 additions & 2 deletions internal/tui/bubbles/git/refs/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ func (b *Bubble) SetBranch(ref *plumbing.Reference) (tea.Model, tea.Cmd) {
}
}

func (b *Bubble) Init() tea.Cmd {
func (b *Bubble) reset() tea.Cmd {
return b.updateItems()
}

func (b *Bubble) Init() tea.Cmd {
return nil
}

func (b *Bubble) SetSize(width, height int) {
b.width = width
b.height = height
Expand Down Expand Up @@ -152,7 +156,7 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyMsg:
switch msg.String() {
case "B":
cmds = append(cmds, b.updateItems())
return b, b.reset()
case "enter", "right", "l":
if b.list.Index() >= 0 {
ref := b.list.SelectedItem().(item).Reference
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/bubbles/git/tree/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (b *Bubble) reset() tea.Cmd {
}

func (b *Bubble) Init() tea.Cmd {
return b.reset()
return nil
}

func (b *Bubble) SetSize(width, height int) {
Expand Down

0 comments on commit 352b06d

Please sign in to comment.