Pause spinner ticks when not refreshing.
All checks were successful
Build & Test / Main (push) Successful in 59s

Also, add a quick-and-dirty model for displaying basic performance
stats, currently just the number of calls to the root Update() and
View() methods.
This commit is contained in:
2024-03-22 21:12:14 -07:00
parent c4dde38d23
commit 270534c0d5
4 changed files with 74 additions and 18 deletions

View File

@@ -108,11 +108,16 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
switch msg := msg.inner.(type) {
case refresh:
m.refreshing = true
return m, func() tea.Msg {
// TODO: log errors
_ = m.math.Refresh(context.TODO())
return Msg{m.math.Asset, m.math}
}
return m, tea.Batch(
func() tea.Msg {
return m.indicator.Tick()
},
func() tea.Msg {
// TODO: log errors
_ = m.math.Refresh(context.TODO())
return Msg{m.math.Asset, m.math}
},
)
case moon.Math:
m.math = msg
refillProperties(&m)
@@ -135,6 +140,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
return m, nil
}
case spinner.TickMsg:
if !m.refreshing {
return m, nil
}
var cmd tea.Cmd
m.indicator, cmd = m.indicator.Update(msg)
return m, cmd