From 0e7eccdc23eccaadf6553edc9fed057e98c32952 Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Wed, 25 Sep 2024 11:43:11 -1000 Subject: [PATCH] Trigger an immediate refresh of the incident list when turning on auto-refresh Auto-refresh should immediately poll for new incidents when enabled, rather than awaiting the PollIncidentsMsg. Signed-off-by: Chris Collins --- pkg/tui/msgHandlers.go | 2 +- pkg/tui/tui.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/tui/msgHandlers.go b/pkg/tui/msgHandlers.go index 0c70292..2d8ca6b 100644 --- a/pkg/tui/msgHandlers.go +++ b/pkg/tui/msgHandlers.go @@ -114,7 +114,7 @@ func (m model) keyMsgHandler(msg tea.Msg) (tea.Model, tea.Cmd) { if key.Matches(msg.(tea.KeyMsg), defaultKeyMap.AutoRefresh) { m.autoRefresh = !m.autoRefresh - return m, nil + return m, updateIncidentList(m.config) } if key.Matches(msg.(tea.KeyMsg), defaultKeyMap.AutoAck) { diff --git a/pkg/tui/tui.go b/pkg/tui/tui.go index 868c6fc..83aeb78 100644 --- a/pkg/tui/tui.go +++ b/pkg/tui/tui.go @@ -117,13 +117,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case setStatusMsg: return m.setStatusMsgHandler(msg) + // Command to trigger a regular poll for new incidents case PollIncidentsMsg: if !m.autoRefresh { return m, nil } - m.setStatus("polling for new incidents...") - return m, func() tea.Msg { return updateIncidentListMsg("sender: PollIncidentsMsg") } + return m, updateIncidentList(m.config) // Command to get an incident by ID case getIncidentMsg: