c7a9618c33d55eaa1491c0fa17df49ba59e87521

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

Message

ref(ui): go back msg

Diff

 1diff --git a/ui/pages/repo/repo.go b/ui/pages/repo/repo.go
 2index 16b21ac3e9f581c242c6edd20b023db91d0dfc19..c6e5be91cde6b148040119b0e10f7abfca452437 100644
 3--- a/ui/pages/repo/repo.go
 4+++ b/ui/pages/repo/repo.go
 5@@ -12,6 +12,7 @@ import (
 6 	"github.com/charmbracelet/soft-serve/config"
 7 	ggit "github.com/charmbracelet/soft-serve/git"
 8 	"github.com/charmbracelet/soft-serve/ui/common"
 9+	"github.com/charmbracelet/soft-serve/ui/components/footer"
10 	"github.com/charmbracelet/soft-serve/ui/components/statusbar"
11 	"github.com/charmbracelet/soft-serve/ui/components/tabs"
12 	"github.com/charmbracelet/soft-serve/ui/git"
13@@ -199,18 +200,23 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
14 		}
15 		if r.selectedRepo != nil {
16 			cmds = append(cmds, r.updateStatusBarCmd)
17-			switch msg := msg.(type) {
18-			case tea.MouseMsg:
19-				switch msg.Type {
20-				case tea.MouseLeft:
21-					id := fmt.Sprintf("%s-url", r.selectedRepo.Repo())
22-					if r.common.Zone.Get(id).InBounds(msg) {
23-						cmds = append(cmds, r.copyUrlCmd())
24-					}
25-				case tea.MouseRight:
26-					if r.common.Zone.Get("repo-main").InBounds(msg) {
27-						cmds = append(cmds, backCmd)
28-					}
29+			urlID := fmt.Sprintf("%s-url", r.selectedRepo.Repo())
30+			if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) {
31+				cmds = append(cmds, r.copyURLCmd())
32+			}
33+		}
34+		switch msg := msg.(type) {
35+		case tea.MouseMsg:
36+			switch msg.Type {
37+			case tea.MouseLeft:
38+				switch {
39+				case r.common.Zone.Get("repo-help").InBounds(msg):
40+					cmds = append(cmds, footer.ToggleFooterCmd)
41+				}
42+			case tea.MouseRight:
43+				switch {
44+				case r.common.Zone.Get("repo-main").InBounds(msg):
45+					cmds = append(cmds, backCmd)
46 				}
47 			}
48 		}
49@@ -285,12 +291,12 @@ func (r *Repo) View() string {
50 		Height(r.common.Height - hm)
51 	main := r.common.Zone.Mark(
52 		"repo-main",
53-		r.panes[r.activeTab].View(),
54+		mainStyle.Render(r.panes[r.activeTab].View()),
55 	)
56 	view := lipgloss.JoinVertical(lipgloss.Top,
57 		r.headerView(),
58 		r.tabs.View(),
59-		mainStyle.Render(main),
60+		main,
61 		r.statusbar.View(),
62 	)
63 	return s.Render(view)
64@@ -375,7 +381,7 @@ func (r *Repo) updateModels(msg tea.Msg) tea.Cmd {
65 	return tea.Batch(cmds...)
66 }
67 
68-func (r *Repo) copyUrlCmd() tea.Cmd {
69+func (r *Repo) copyURLCmd() tea.Cmd {
70 	r.copyURL = time.Now()
71 	return tea.Batch(
72 		func() tea.Msg {
73diff --git a/ui/ui.go b/ui/ui.go
74index 7e479df2d93737a783ea6a2255c5c5f211c22689..dd482ac68c14bf39d343072410bed90ec1a7de67 100644
75--- a/ui/ui.go
76+++ b/ui/ui.go
77@@ -205,10 +205,10 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
78 				ui.showFooter = true
79 			}
80 		case tea.MouseMsg:
81-			if msg.Type == tea.MouseLeft {
82+			switch msg.Type {
83+			case tea.MouseLeft:
84 				switch {
85-				case ui.common.Zone.Get("repo-help").InBounds(msg),
86-					ui.common.Zone.Get("footer").InBounds(msg):
87+				case ui.common.Zone.Get("footer").InBounds(msg):
88 					cmds = append(cmds, footer.ToggleFooterCmd)
89 				}
90 			}