Skip to content

Commit 6d0a9ed

Browse files
committed
wip: bug fixes
1 parent 7e3ad2e commit 6d0a9ed

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

ui/pages/transaction/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import (
66
)
77

88
func (m ViewModel) View() string {
9-
pad := strings.Repeat("\n", m.Height/2-1)
9+
pad := strings.Repeat("\n", max(0, m.Height/2-1))
1010
return lipgloss.JoinVertical(lipgloss.Center, pad, "TODO", pad, m.controls.View())
1111
}

ui/viewport.go

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,11 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7373
m.status, cmd = m.status.HandleMessage(msg)
7474
cmds = append(cmds, cmd)
7575

76-
// Get Page Updates
77-
switch m.page {
78-
case AccountsPage:
79-
m.accountsPage, cmd = m.accountsPage.HandleMessage(msg)
80-
case KeysPage:
81-
m.keysPage, cmd = m.keysPage.HandleMessage(msg)
82-
case GeneratePage:
83-
m.generatePage, cmd = m.generatePage.HandleMessage(msg)
84-
case TransactionPage:
85-
m.transactionPage, cmd = m.transactionPage.HandleMessage(msg)
86-
}
87-
cmds = append(cmds, cmd)
88-
8976
switch msg := msg.(type) {
90-
// When the participation keys update
77+
// When the state updates
9178
case internal.StateModel:
9279
m.Data = &msg
93-
// Navigate to the transaction page when a partkey is selected
80+
// Navigate to the transaction page when a partkey is selected
9481
case *api.ParticipationKey:
9582
m.page = TransactionPage
9683
// Navigate to the keys page when an account is selected
@@ -144,25 +131,45 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
144131
m.PageWidth = msg.Width
145132
m.PageHeight = max(0, msg.Height-lipgloss.Height(m.headerView())-1)
146133

134+
// Custom size message
147135
pageMsg := tea.WindowSizeMsg{
148136
Height: m.PageHeight,
149137
Width: m.PageWidth,
150138
}
151139

152140
// Handle the page resize event
141+
//switch m.page {
142+
//case AccountsPage:
153143
m.accountsPage, cmd = m.accountsPage.HandleMessage(pageMsg)
154144
cmds = append(cmds, cmd)
145+
//case KeysPage:
155146
m.keysPage, cmd = m.keysPage.HandleMessage(pageMsg)
156147
cmds = append(cmds, cmd)
148+
//case GeneratePage:
157149
m.generatePage, cmd = m.generatePage.HandleMessage(pageMsg)
158150
cmds = append(cmds, cmd)
151+
//case TransactionPage:
159152
m.transactionPage, cmd = m.transactionPage.HandleMessage(pageMsg)
160153
cmds = append(cmds, cmd)
161-
154+
//}
155+
cmds = append(cmds, cmd)
162156
// Avoid triggering commands again
163157
return m, tea.Batch(cmds...)
158+
159+
}
160+
// Get Page Updates
161+
switch m.page {
162+
case AccountsPage:
163+
m.accountsPage, cmd = m.accountsPage.HandleMessage(msg)
164+
case KeysPage:
165+
m.keysPage, cmd = m.keysPage.HandleMessage(msg)
166+
case GeneratePage:
167+
m.generatePage, cmd = m.generatePage.HandleMessage(msg)
168+
case TransactionPage:
169+
m.transactionPage, cmd = m.transactionPage.HandleMessage(msg)
164170
}
165-
return m.handlePages(cmds, msg)
171+
cmds = append(cmds, cmd)
172+
return m, tea.Batch(cmds...)
166173
}
167174

168175
// View renders the viewport.Model

0 commit comments

Comments
 (0)