Fix latency issue

This commit is contained in:
Martin Pander
2026-09-11 13:17:04 +02:00
parent 6b1418fc71
commit 6fbe575471
4 changed files with 26 additions and 17 deletions

View File

@@ -142,14 +142,14 @@ func (p *TimePage) renderHeader() string {
start.Year())
}
slog.Info("Rendering time page header", "text", headerText, "timespan", p.selectedTimespan)
slog.Debug("Rendering time page header", "text", headerText, "timespan", p.selectedTimespan)
// Make header bold and prominent
headerStyle := lipgloss.NewStyle().Bold(true).Foreground(p.common.Styles.Palette.Accent.GetForeground())
return headerStyle.Render(headerText)
}
func (p *TimePage) Init() tea.Cmd {
return tea.Batch(p.getIntervals(), doTick())
return p.getIntervals()
}
func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
@@ -177,17 +177,11 @@ func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
p.common.TW.StopActiveTasks()
p.common.TW.StartTask(msg.Task)
cmds = append(cmds, p.getIntervals())
cmds = append(cmds, doTick())
}
case RefreshIntervalsMsg:
cmds = append(cmds, p.getIntervals())
cmds = append(cmds, doTick())
case BackMsg:
// Restart tick loop when returning from subpage
cmds = append(cmds, doTick())
case tickMsg:
cmds = append(cmds, p.getIntervals())
cmds = append(cmds, doTick())
case tea.KeyMsg:
switch {
case key.Matches(msg, p.common.Keymap.Quit):
@@ -232,7 +226,6 @@ func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
p.pendingSyncAction = "start"
}
cmds = append(cmds, p.getIntervals())
cmds = append(cmds, doTick())
return p, tea.Batch(cmds...)
}
case key.Matches(msg, p.common.Keymap.Delete):
@@ -240,7 +233,7 @@ func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if row != nil {
interval := (*timewarrior.Interval)(row)
p.common.TimeW.DeleteInterval(interval.ID)
return p, tea.Batch(p.getIntervals(), doTick())
return p, p.getIntervals()
}
case key.Matches(msg, p.common.Keymap.Edit):
row := p.intervals.SelectedRow()
@@ -261,11 +254,11 @@ func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if row != nil {
interval := (*timewarrior.Interval)(row)
p.common.TimeW.FillInterval(interval.ID)
return p, tea.Batch(p.getIntervals(), doTick())
return p, p.getIntervals()
}
case key.Matches(msg, p.common.Keymap.Undo):
p.common.TimeW.Undo()
return p, tea.Batch(p.getIntervals(), doTick())
return p, p.getIntervals()
case key.Matches(msg, p.common.Keymap.Join):
row := p.intervals.SelectedRow()
if row != nil {
@@ -273,7 +266,7 @@ func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Don't join if this is the last (oldest) interval
if interval.ID < len(p.data) {
p.common.TimeW.JoinInterval(interval.ID)
return p, tea.Batch(p.getIntervals(), doTick())
return p, p.getIntervals()
}
}
}
@@ -313,7 +306,7 @@ func (p *TimePage) View() string {
tableHeight := lipgloss.Height(tableView)
headerHeight := lipgloss.Height(header)
slog.Info("TimePage View rendered",
slog.Debug("TimePage View rendered",
"headerLen", len(header),
"dataCount", len(p.data),
"headerHeight", headerHeight,