f3e2b7fe776a7e9fcec7166f4c4e4e8b2375241a

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

Message

refactor: rename variables

Diff

  1diff --git a/internal/tui/bubbles/git/bubble.go b/internal/tui/bubbles/git/bubble.go
  2index 4a47467fe37ed64467ef4ac539f53dd9f0ab7b4a..d2c6bb0025e16c180d52f231f2a76ef4d978fa9f 100644
  3--- a/internal/tui/bubbles/git/bubble.go
  4+++ b/internal/tui/bubbles/git/bubble.go
  5@@ -16,17 +16,17 @@ const (
  6 	repoNameMaxWidth = 32
  7 )
  8 
  9-type pageState int
 10+type state int
 11 
 12 const (
 13-	aboutPage pageState = iota
 14-	refsPage
 15-	logPage
 16-	treePage
 17+	aboutState state = iota
 18+	refsState
 19+	logState
 20+	treeState
 21 )
 22 
 23 type Bubble struct {
 24-	state        pageState
 25+	state        state
 26 	repo         types.Repo
 27 	height       int
 28 	heightMargin int
 29@@ -40,7 +40,7 @@ type Bubble struct {
 30 func NewBubble(repo types.Repo, styles *style.Styles, width, wm, height, hm int) *Bubble {
 31 	b := &Bubble{
 32 		repo:         repo,
 33-		state:        aboutPage,
 34+		state:        aboutState,
 35 		width:        width,
 36 		widthMargin:  wm,
 37 		height:       height,
 38@@ -50,10 +50,10 @@ func NewBubble(repo types.Repo, styles *style.Styles, width, wm, height, hm int)
 39 		ref:          repo.GetHEAD(),
 40 	}
 41 	heightMargin := hm + lipgloss.Height(b.headerView())
 42-	b.boxes[aboutPage] = about.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
 43-	b.boxes[refsPage] = refs.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
 44-	b.boxes[logPage] = log.NewBubble(repo, b.style, width, wm, height, heightMargin)
 45-	b.boxes[treePage] = tree.NewBubble(repo, b.style, width, wm, height, heightMargin)
 46+	b.boxes[aboutState] = about.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
 47+	b.boxes[refsState] = refs.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
 48+	b.boxes[logState] = log.NewBubble(repo, b.style, width, wm, height, heightMargin)
 49+	b.boxes[treeState] = tree.NewBubble(repo, b.style, width, wm, height, heightMargin)
 50 	return b
 51 }
 52 
 53@@ -68,27 +68,20 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 54 		if b.repo.Name() != "config" {
 55 			switch msg.String() {
 56 			case "R":
 57-				b.state = aboutPage
 58+				b.state = aboutState
 59 			case "B":
 60-				b.state = refsPage
 61+				b.state = refsState
 62 			case "C":
 63-				b.state = logPage
 64+				b.state = logState
 65 			case "F":
 66-				b.state = treePage
 67+				b.state = treeState
 68 			}
 69 		}
 70 	case tea.WindowSizeMsg:
 71 		b.width = msg.Width
 72 		b.height = msg.Height
 73-		for i, bx := range b.boxes {
 74-			m, cmd := bx.Update(msg)
 75-			b.boxes[i] = m
 76-			if cmd != nil {
 77-				cmds = append(cmds, cmd)
 78-			}
 79-		}
 80 	case refs.RefMsg:
 81-		b.state = treePage
 82+		b.state = treeState
 83 		b.ref = msg
 84 		for i, bx := range b.boxes {
 85 			m, cmd := bx.Update(msg)
 86diff --git a/internal/tui/bubbles/repo/bubble.go b/internal/tui/bubbles/repo/bubble.go
 87index d96d3b10ca718fa5689fe5307fffd32c1bf7c8d7..5ba6f8fcacea26ea8af02c61007f1911802ab550 100644
 88--- a/internal/tui/bubbles/repo/bubble.go
 89+++ b/internal/tui/bubbles/repo/bubble.go
 90@@ -33,18 +33,18 @@ type Bubble struct {
 91 	Active bool
 92 }
 93 
 94-func NewBubble(name, host string, port int, repo gittypes.Repo, styles *style.Styles, width, wm, height, hm int) *Bubble {
 95+func NewBubble(repo gittypes.Repo, host string, port int, styles *style.Styles, width, wm, height, hm int) *Bubble {
 96 	b := &Bubble{
 97-		name:         name,
 98+		name:         repo.Name(),
 99 		host:         host,
100 		port:         port,
101-		repo:         repo,
102 		width:        width,
103 		widthMargin:  wm,
104 		height:       height,
105 		heightMargin: hm,
106 		styles:       styles,
107 	}
108+	b.repo = repo
109 	b.box = gitui.NewBubble(repo, styles, width, wm+styles.RepoBody.GetHorizontalBorderSize(), height, hm+lipgloss.Height(b.headerView())-styles.RepoBody.GetVerticalBorderSize())
110 	return b
111 }
112diff --git a/internal/tui/commands.go b/internal/tui/commands.go
113index 7eef46ba64f531f04173c8bdb047dec0e69a17d7..20d3b16aaa4a541033f7af8c01d1f0d686d5907f 100644
114--- a/internal/tui/commands.go
115+++ b/internal/tui/commands.go
116@@ -115,7 +115,7 @@ func (b *Bubble) newMenuEntry(name string, rn string) (MenuEntry, error) {
117 		lipgloss.Height(b.footerView()) +
118 		b.styles.RepoBody.GetVerticalFrameSize() +
119 		b.styles.App.GetVerticalMargins()
120-	rb := repo.NewBubble(rn, b.config.Host, b.config.Port, r, b.styles, b.width, boxLeftWidth, b.height, heightMargin)
121+	rb := repo.NewBubble(r, b.config.Host, b.config.Port, b.styles, b.width, boxLeftWidth, b.height, heightMargin)
122 	initCmd := rb.Init()
123 	msg := initCmd()
124 	switch msg := msg.(type) {