repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
f45122a
parent
6a5926c
author
Eric Bower
date
2024-05-17 16:03:31 +0000 UTC
chore(tui): cleanup
3 files changed,  +21, -20
M tui/notifications/notifications.go
+2, -2
 1@@ -92,9 +92,9 @@ func (m Model) Init() tea.Cmd {
 2 func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 3 	switch msg := msg.(type) {
 4 	case tea.WindowSizeMsg:
 5-		m.viewport.Width = headerWidth(m.shared.Width)
 6+		m.viewport.Width = headerWidth(msg.Width)
 7 		hh := headerHeight(m.shared)
 8-		m.viewport.Height = m.shared.Height - hh
 9+		m.viewport.Height = msg.Height - hh
10 
11 	case tea.KeyMsg:
12 		switch msg.String() {
M tui/plus/plus.go
+2, -3
 1@@ -90,7 +90,6 @@ func headerWidth(w int) int {
 2 func NewModel(shared common.SharedModel) Model {
 3 	hh := headerHeight(shared)
 4 	viewport := viewport.New(headerWidth(shared.Width), shared.Height-hh)
 5-	viewport.YPosition = hh
 6 	if shared.User != nil {
 7 		viewport.SetContent(PlusView(shared.User.Name))
 8 	}
 9@@ -109,9 +108,9 @@ func (m Model) Init() tea.Cmd {
10 func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
11 	switch msg := msg.(type) {
12 	case tea.WindowSizeMsg:
13-		m.viewport.Width = headerWidth(m.shared.Width)
14+		m.viewport.Width = headerWidth(msg.Width)
15 		hh := headerHeight(m.shared)
16-		m.viewport.Height = m.shared.Height - hh
17+		m.viewport.Height = msg.Height - hh
18 	case tea.KeyMsg:
19 		switch msg.String() {
20 		case "q", "esc":
M tui/ui.go
+17, -15
 1@@ -51,23 +51,10 @@ func (m *UI) updateActivePage(msg tea.Msg) tea.Cmd {
 2 	return cmd
 3 }
 4 
 5-func (m *UI) updateModels(msg tea.Msg) tea.Cmd {
 6-	cmds := []tea.Cmd{}
 7-	for i, page := range m.pages {
 8-		if page == nil {
 9-			continue
10-		}
11-		nm, cmd := page.Update(msg)
12-		m.pages[i] = nm
13-		cmds = append(cmds, cmd)
14-	}
15-	return tea.Batch(cmds...)
16-}
17-
18 func (m *UI) Init() tea.Cmd {
19 	// header height is required to calculate viewport for
20 	// some pages
21-	m.shared.HeaderHeight = lipgloss.Height(m.header())
22+	m.shared.HeaderHeight = lipgloss.Height(m.header()) + 1
23 	user, err := findUser(m.shared)
24 	if err != nil {
25 		wish.Errorln(m.shared.Session, err)
26@@ -103,7 +90,6 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
27 	case tea.WindowSizeMsg:
28 		m.shared.Width = msg.Width
29 		m.shared.Height = msg.Height
30-		return m, m.updateModels(msg)
31 
32 	case tea.KeyMsg:
33 		switch msg.Type {
34@@ -180,3 +166,19 @@ func (m *UI) View() string {
35 	)
36 	return m.shared.Styles.App.Render(str)
37 }
38+
39+/*
40+TODO: I dont think we need this but keeping for a bit
41+func (m *UI) updateModels(msg tea.Msg) tea.Cmd {
42+	cmds := []tea.Cmd{}
43+	for i, page := range m.pages {
44+		if page == nil {
45+			continue
46+		}
47+		nm, cmd := page.Update(msg)
48+		m.pages[i] = nm
49+		cmds = append(cmds, cmd)
50+	}
51+	return tea.Batch(cmds...)
52+}
53+*/