refactor: rename variables

Ayman Bagabas created

Change summary

internal/tui/bubbles/git/bubble.go  | 39 ++++++++++++------------------
internal/tui/bubbles/repo/bubble.go |  6 ++--
internal/tui/commands.go            |  2 
3 files changed, 20 insertions(+), 27 deletions(-)

Detailed changes

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

@@ -16,17 +16,17 @@ const (
 	repoNameMaxWidth = 32
 )
 
-type pageState int
+type state int
 
 const (
-	aboutPage pageState = iota
-	refsPage
-	logPage
-	treePage
+	aboutState state = iota
+	refsState
+	logState
+	treeState
 )
 
 type Bubble struct {
-	state        pageState
+	state        state
 	repo         types.Repo
 	height       int
 	heightMargin int
@@ -40,7 +40,7 @@ type Bubble struct {
 func NewBubble(repo types.Repo, styles *style.Styles, width, wm, height, hm int) *Bubble {
 	b := &Bubble{
 		repo:         repo,
-		state:        aboutPage,
+		state:        aboutState,
 		width:        width,
 		widthMargin:  wm,
 		height:       height,
@@ -50,10 +50,10 @@ func NewBubble(repo types.Repo, styles *style.Styles, width, wm, height, hm int)
 		ref:          repo.GetHEAD(),
 	}
 	heightMargin := hm + lipgloss.Height(b.headerView())
-	b.boxes[aboutPage] = about.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
-	b.boxes[refsPage] = refs.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
-	b.boxes[logPage] = log.NewBubble(repo, b.style, width, wm, height, heightMargin)
-	b.boxes[treePage] = tree.NewBubble(repo, b.style, width, wm, height, heightMargin)
+	b.boxes[aboutState] = about.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
+	b.boxes[refsState] = refs.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin)
+	b.boxes[logState] = log.NewBubble(repo, b.style, width, wm, height, heightMargin)
+	b.boxes[treeState] = tree.NewBubble(repo, b.style, width, wm, height, heightMargin)
 	return b
 }
 
@@ -68,27 +68,20 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if b.repo.Name() != "config" {
 			switch msg.String() {
 			case "R":
-				b.state = aboutPage
+				b.state = aboutState
 			case "B":
-				b.state = refsPage
+				b.state = refsState
 			case "C":
-				b.state = logPage
+				b.state = logState
 			case "F":
-				b.state = treePage
+				b.state = treeState
 			}
 		}
 	case tea.WindowSizeMsg:
 		b.width = msg.Width
 		b.height = msg.Height
-		for i, bx := range b.boxes {
-			m, cmd := bx.Update(msg)
-			b.boxes[i] = m
-			if cmd != nil {
-				cmds = append(cmds, cmd)
-			}
-		}
 	case refs.RefMsg:
-		b.state = treePage
+		b.state = treeState
 		b.ref = msg
 		for i, bx := range b.boxes {
 			m, cmd := bx.Update(msg)

internal/tui/bubbles/repo/bubble.go 🔗

@@ -33,18 +33,18 @@ type Bubble struct {
 	Active bool
 }
 
-func NewBubble(name, host string, port int, repo gittypes.Repo, styles *style.Styles, width, wm, height, hm int) *Bubble {
+func NewBubble(repo gittypes.Repo, host string, port int, styles *style.Styles, width, wm, height, hm int) *Bubble {
 	b := &Bubble{
-		name:         name,
+		name:         repo.Name(),
 		host:         host,
 		port:         port,
-		repo:         repo,
 		width:        width,
 		widthMargin:  wm,
 		height:       height,
 		heightMargin: hm,
 		styles:       styles,
 	}
+	b.repo = repo
 	b.box = gitui.NewBubble(repo, styles, width, wm+styles.RepoBody.GetHorizontalBorderSize(), height, hm+lipgloss.Height(b.headerView())-styles.RepoBody.GetVerticalBorderSize())
 	return b
 }

internal/tui/commands.go 🔗

@@ -115,7 +115,7 @@ func (b *Bubble) newMenuEntry(name string, rn string) (MenuEntry, error) {
 		lipgloss.Height(b.footerView()) +
 		b.styles.RepoBody.GetVerticalFrameSize() +
 		b.styles.App.GetVerticalMargins()
-	rb := repo.NewBubble(rn, b.config.Host, b.config.Port, r, b.styles, b.width, boxLeftWidth, b.height, heightMargin)
+	rb := repo.NewBubble(r, b.config.Host, b.config.Port, b.styles, b.width, boxLeftWidth, b.height, heightMargin)
 	initCmd := rb.Init()
 	msg := initCmd()
 	switch msg := msg.(type) {