028e9ca57b881576a532ab44af167143ebfc8cb3

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

Message

fix(ui): update log items when toggling help footer

Diff

 1diff --git a/ui/components/footer/footer.go b/ui/components/footer/footer.go
 2index 6d724eb230acdb06052b716e4962484f6daf7c3e..e0f8c0e262f8cbee167a6c0e93e9d3e447d3fdbd 100644
 3--- a/ui/components/footer/footer.go
 4+++ b/ui/components/footer/footer.go
 5@@ -8,6 +8,9 @@ import (
 6 	"github.com/charmbracelet/soft-serve/ui/common"
 7 )
 8 
 9+// ToggleFooterMsg is a message sent to show/hide the footer.
10+type ToggleFooterMsg struct{}
11+
12 // Footer is a Bubble Tea model that displays help and other info.
13 type Footer struct {
14 	common common.Common
15@@ -83,3 +86,8 @@ func (f *Footer) SetShowAll(show bool) {
16 func (f *Footer) Height() int {
17 	return lipgloss.Height(f.View())
18 }
19+
20+// ToggleFooterCmd sends a ToggleFooterMsg to show/hide the help footer.
21+func ToggleFooterCmd() tea.Msg {
22+	return ToggleFooterMsg{}
23+}
24diff --git a/ui/pages/repo/log.go b/ui/pages/repo/log.go
25index 44619f9eaca2778021b2a80e49eeae801300b94d..cd624e4402b76ee5e66837485c6b3d65a4eec295 100644
26--- a/ui/pages/repo/log.go
27+++ b/ui/pages/repo/log.go
28@@ -12,6 +12,7 @@ import (
29 	"github.com/charmbracelet/lipgloss"
30 	ggit "github.com/charmbracelet/soft-serve/git"
31 	"github.com/charmbracelet/soft-serve/ui/common"
32+	"github.com/charmbracelet/soft-serve/ui/components/footer"
33 	"github.com/charmbracelet/soft-serve/ui/components/selector"
34 	"github.com/charmbracelet/soft-serve/ui/components/viewport"
35 	"github.com/charmbracelet/soft-serve/ui/git"
36@@ -274,6 +275,8 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
37 			// stop loading after setting the viewport content
38 			l.stopLoading(),
39 		)
40+	case footer.ToggleFooterMsg:
41+		cmds = append(cmds, l.updateCommitsCmd)
42 	case tea.WindowSizeMsg:
43 		if l.selectedCommit != nil && l.currentDiff != nil {
44 			l.vp.SetContent(
45diff --git a/ui/ui.go b/ui/ui.go
46index 1543146220d2aed1a2a073a72d8c0e343fe38bb1..c87c69adec4cbe3c5429a1309da094e29b122907 100644
47--- a/ui/ui.go
48+++ b/ui/ui.go
49@@ -184,11 +184,7 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
50 				// Always show the footer on error.
51 				ui.showFooter = ui.footer.ShowAll()
52 			case key.Matches(msg, ui.common.KeyMap.Help):
53-				ui.footer.SetShowAll(!ui.footer.ShowAll())
54-				// Show the footer when on repo page and shot all help.
55-				if ui.error == nil && ui.activePage == repoPage {
56-					ui.showFooter = !ui.showFooter
57-				}
58+				cmds = append(cmds, footer.ToggleFooterCmd)
59 			case key.Matches(msg, ui.common.KeyMap.Quit):
60 				return ui, tea.Quit
61 			case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back):
62@@ -197,6 +193,12 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
63 				ui.showFooter = true
64 			}
65 		}
66+	case footer.ToggleFooterMsg:
67+		ui.footer.SetShowAll(!ui.footer.ShowAll())
68+		// Show the footer when on repo page and shot all help.
69+		if ui.error == nil && ui.activePage == repoPage {
70+			ui.showFooter = !ui.showFooter
71+		}
72 	case repo.RepoMsg:
73 		ui.activePage = repoPage
74 		// Show the footer on repo page if show all is set.