352b06d5795266d6c8a994fec028672ce7435576

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: lazy load git tui bubbles

Diff

 1diff --git a/internal/tui/bubbles/git/log/bubble.go b/internal/tui/bubbles/git/log/bubble.go
 2index 773784e7ab4fe9bc6f0e979b96ef0a9314431326..600011791a4424921cd0a12d8f4daf6ef0e3bf0c 100644
 3--- a/internal/tui/bubbles/git/log/bubble.go
 4+++ b/internal/tui/bubbles/git/log/bubble.go
 5@@ -158,7 +158,7 @@ func (b *Bubble) GotoTop() {
 6 }
 7 
 8 func (b *Bubble) Init() tea.Cmd {
 9-	return b.reset()
10+	return nil
11 }
12 
13 func (b *Bubble) SetSize(width, height int) {
14diff --git a/internal/tui/bubbles/git/refs/bubble.go b/internal/tui/bubbles/git/refs/bubble.go
15index c180d128771d1cab56ecc810f102dd3ba09953f5..53fec666a1aea7797338fdfabd5a7dbf407371f1 100644
16--- a/internal/tui/bubbles/git/refs/bubble.go
17+++ b/internal/tui/bubbles/git/refs/bubble.go
18@@ -106,10 +106,14 @@ func (b *Bubble) SetBranch(ref *plumbing.Reference) (tea.Model, tea.Cmd) {
19 	}
20 }
21 
22-func (b *Bubble) Init() tea.Cmd {
23+func (b *Bubble) reset() tea.Cmd {
24 	return b.updateItems()
25 }
26 
27+func (b *Bubble) Init() tea.Cmd {
28+	return nil
29+}
30+
31 func (b *Bubble) SetSize(width, height int) {
32 	b.width = width
33 	b.height = height
34@@ -152,7 +156,7 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
35 	case tea.KeyMsg:
36 		switch msg.String() {
37 		case "B":
38-			cmds = append(cmds, b.updateItems())
39+			return b, b.reset()
40 		case "enter", "right", "l":
41 			if b.list.Index() >= 0 {
42 				ref := b.list.SelectedItem().(item).Reference
43diff --git a/internal/tui/bubbles/git/tree/bubble.go b/internal/tui/bubbles/git/tree/bubble.go
44index f16a9d71b14b4bcc356fcd44d2e859a3e90aeff5..805aa5865088bc0ddfd734dd241312f67db9ac6f 100644
45--- a/internal/tui/bubbles/git/tree/bubble.go
46+++ b/internal/tui/bubbles/git/tree/bubble.go
47@@ -168,7 +168,7 @@ func (b *Bubble) reset() tea.Cmd {
48 }
49 
50 func (b *Bubble) Init() tea.Cmd {
51-	return b.reset()
52+	return nil
53 }
54 
55 func (b *Bubble) SetSize(width, height int) {