Skip to content

Commit

Permalink
Trigger an immediate refresh of the incident list when turning on
Browse files Browse the repository at this point in the history
auto-refresh

Auto-refresh should immediately poll for new incidents when enabled,
rather than awaiting the PollIncidentsMsg.

Signed-off-by: Chris Collins <[email protected]>
  • Loading branch information
clcollins committed Oct 1, 2024
1 parent 487b639 commit 0e7eccd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/tui/msgHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0e7eccd

Please sign in to comment.