clean

Ayman Bagabas created

Change summary

ui/pages/repo/readme.go | 13 +++++++++++--
ui/pages/repo/repo.go   | 12 +++++++++---
ui/ui.go                |  1 -
3 files changed, 20 insertions(+), 6 deletions(-)

Detailed changes

ui/pages/repo/readme.go 🔗

@@ -10,6 +10,8 @@ import (
 	"github.com/charmbracelet/soft-serve/ui/git"
 )
 
+type ReadmeMsg struct{}
+
 // Readme is the readme component page.
 type Readme struct {
 	common common.Common
@@ -67,7 +69,10 @@ func (r *Readme) Init() tea.Cmd {
 	}
 	rm, rp := r.repo.Readme()
 	r.code.GotoTop()
-	return r.code.SetContent(rm, rp)
+	return tea.Batch(
+		r.code.SetContent(rm, rp),
+		r.updateReadmeCmd,
+	)
 }
 
 // Update implements tea.Model.
@@ -94,7 +99,7 @@ func (r *Readme) View() string {
 	return r.code.View()
 }
 
-// StausBarValue implements statusbar.StatusBar.
+// StatusBarValue implements statusbar.StatusBar.
 func (r *Readme) StatusBarValue() string {
 	return ""
 }
@@ -103,3 +108,7 @@ func (r *Readme) StatusBarValue() string {
 func (r *Readme) StatusBarInfo() string {
 	return fmt.Sprintf("☰ %.f%%", r.code.ScrollPercent()*100)
 }
+
+func (r *Readme) updateReadmeCmd() tea.Msg {
+	return ReadmeMsg{}
+}

ui/pages/repo/repo.go 🔗

@@ -16,6 +16,13 @@ import (
 	"github.com/charmbracelet/soft-serve/ui/git"
 )
 
+type state int
+
+const (
+	loadingState state = iota
+	loadedState
+)
+
 type tab int
 
 const (
@@ -50,7 +57,6 @@ type RefMsg *ggit.Reference
 type Repo struct {
 	common       common.Common
 	cfg          *config.Config
-	rs           git.GitRepoSource
 	selectedRepo git.GitRepo
 	activeTab    tab
 	tabs         *tabs.Tabs
@@ -60,7 +66,7 @@ type Repo struct {
 }
 
 // New returns a new Repo.
-func New(cfg *config.Config, rs git.GitRepoSource, c common.Common) *Repo {
+func New(cfg *config.Config, c common.Common) *Repo {
 	sb := statusbar.New(c)
 	ts := make([]string, lastTab)
 	// Tabs must match the order of tab constants above.
@@ -84,7 +90,6 @@ func New(cfg *config.Config, rs git.GitRepoSource, c common.Common) *Repo {
 	r := &Repo{
 		cfg:       cfg,
 		common:    c,
-		rs:        rs,
 		tabs:      tb,
 		statusbar: sb,
 		boxes:     boxes,
@@ -186,6 +191,7 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		if r.selectedRepo != nil {
 			cmds = append(cmds, r.updateStatusBarCmd)
 		}
+	case ReadmeMsg:
 	case FileItemsMsg:
 		f, cmd := r.boxes[filesTab].Update(msg)
 		r.boxes[filesTab] = f.(*Files)

ui/ui.go 🔗

@@ -142,7 +142,6 @@ func (ui *UI) Init() tea.Cmd {
 	)
 	ui.pages[repoPage] = repo.New(
 		ui.cfg,
-		ui.rs,
 		ui.common,
 	)
 	ui.SetSize(ui.common.Width, ui.common.Height)