diff --git a/ui/pages/repo/readme.go b/ui/pages/repo/readme.go index b5062c7e654e2b9a264a9ee7d108a4112e8c593f..8605d320545e323fae40e2a7c0d6dd3761a03732 100644 --- a/ui/pages/repo/readme.go +++ b/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{} +} diff --git a/ui/pages/repo/repo.go b/ui/pages/repo/repo.go index 6956fa08be69b47046e483875b9106884b93d862..dc6b1f0b96f72fe8d0308864c717ebbc11b531c8 100644 --- a/ui/pages/repo/repo.go +++ b/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) diff --git a/ui/ui.go b/ui/ui.go index bc012f544e2b6dbdd568b142a42e3e268c42810b..052e5ad654904d1cbacc960f97645d7dde2f373a 100644 --- a/ui/ui.go +++ b/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)