fix: lazy load git tui bubbles

Ayman Bagabas created

Change summary

internal/tui/bubbles/git/log/bubble.go  | 2 +-
internal/tui/bubbles/git/refs/bubble.go | 8 ++++++--
internal/tui/bubbles/git/tree/bubble.go | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)

Detailed changes

internal/tui/bubbles/git/log/bubble.go 🔗

@@ -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) {

internal/tui/bubbles/git/refs/bubble.go 🔗

@@ -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
@@ -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

internal/tui/bubbles/git/tree/bubble.go 🔗

@@ -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) {