diff --git a/ui/components/footer/footer.go b/ui/components/footer/footer.go index 6d724eb230acdb06052b716e4962484f6daf7c3e..e0f8c0e262f8cbee167a6c0e93e9d3e447d3fdbd 100644 --- a/ui/components/footer/footer.go +++ b/ui/components/footer/footer.go @@ -8,6 +8,9 @@ import ( "github.com/charmbracelet/soft-serve/ui/common" ) +// ToggleFooterMsg is a message sent to show/hide the footer. +type ToggleFooterMsg struct{} + // Footer is a Bubble Tea model that displays help and other info. type Footer struct { common common.Common @@ -83,3 +86,8 @@ func (f *Footer) SetShowAll(show bool) { func (f *Footer) Height() int { return lipgloss.Height(f.View()) } + +// ToggleFooterCmd sends a ToggleFooterMsg to show/hide the help footer. +func ToggleFooterCmd() tea.Msg { + return ToggleFooterMsg{} +} diff --git a/ui/pages/repo/log.go b/ui/pages/repo/log.go index 44619f9eaca2778021b2a80e49eeae801300b94d..cd624e4402b76ee5e66837485c6b3d65a4eec295 100644 --- a/ui/pages/repo/log.go +++ b/ui/pages/repo/log.go @@ -12,6 +12,7 @@ import ( "github.com/charmbracelet/lipgloss" ggit "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/soft-serve/ui/common" + "github.com/charmbracelet/soft-serve/ui/components/footer" "github.com/charmbracelet/soft-serve/ui/components/selector" "github.com/charmbracelet/soft-serve/ui/components/viewport" "github.com/charmbracelet/soft-serve/ui/git" @@ -274,6 +275,8 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // stop loading after setting the viewport content l.stopLoading(), ) + case footer.ToggleFooterMsg: + cmds = append(cmds, l.updateCommitsCmd) case tea.WindowSizeMsg: if l.selectedCommit != nil && l.currentDiff != nil { l.vp.SetContent( diff --git a/ui/ui.go b/ui/ui.go index 1543146220d2aed1a2a073a72d8c0e343fe38bb1..c87c69adec4cbe3c5429a1309da094e29b122907 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -184,11 +184,7 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Always show the footer on error. ui.showFooter = ui.footer.ShowAll() case key.Matches(msg, ui.common.KeyMap.Help): - ui.footer.SetShowAll(!ui.footer.ShowAll()) - // Show the footer when on repo page and shot all help. - if ui.error == nil && ui.activePage == repoPage { - ui.showFooter = !ui.showFooter - } + cmds = append(cmds, footer.ToggleFooterCmd) case key.Matches(msg, ui.common.KeyMap.Quit): return ui, tea.Quit case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back): @@ -197,6 +193,12 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ui.showFooter = true } } + case footer.ToggleFooterMsg: + ui.footer.SetShowAll(!ui.footer.ShowAll()) + // Show the footer when on repo page and shot all help. + if ui.error == nil && ui.activePage == repoPage { + ui.showFooter = !ui.showFooter + } case repo.RepoMsg: ui.activePage = repoPage // Show the footer on repo page if show all is set.