Skip to content

Commit

Permalink
fixes #415
Browse files Browse the repository at this point in the history
  • Loading branch information
martindstone committed Mar 1, 2024
1 parent 43ec762 commit 385317a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const NumAlertsComponent = ({
};
const getAlertsForIncidents = useCallback(
(ids) => {
dispatch(getAlertsForIncidentsAsyncConnected(ids));
dispatch(getAlertsForIncidentsAsyncConnected(ids, true));
},
[dispatch],
);
Expand Down
3 changes: 2 additions & 1 deletion src/redux/incidents/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export const getIncidentsAsync = () => ({
type: FETCH_INCIDENTS_REQUESTED,
});

export const getAlertsForIncidentsAsync = (incidentIds) => ({
export const getAlertsForIncidentsAsync = (incidentIds, isRefetch = false) => ({
type: FETCH_ALERTS_FOR_INCIDENTS_REQUESTED,
incidentIds,
isRefetch,
});

export const getNotesForIncidentsAsync = (incidentIds) => ({
Expand Down
24 changes: 13 additions & 11 deletions src/redux/incidents/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ const incidents = produce(
break;

case FETCH_ALERTS_FOR_INCIDENTS_REQUESTED:
draft.incidentAlerts = {
...draft.incidentAlerts,
// dict with keys as the strings of incident ids array and values as { status: 'fetching' }
...action.incidentIds.reduce((acc, incidentId) => {
// eslint-disable-next-line no-param-reassign
acc[incidentId] = {
status: 'fetching',
};
return acc;
}, {}),
};
if (!(action.isRefetch)) {
draft.incidentAlerts = {
...draft.incidentAlerts,
// dict with keys as the strings of incident ids array and values as { status: 'fetching' }
...action.incidentIds.reduce((acc, incidentId) => {
// eslint-disable-next-line no-param-reassign
acc[incidentId] = {
status: 'fetching',
};
return acc;
}, {}),
};
}
draft.status = FETCH_ALERTS_FOR_INCIDENTS_REQUESTED;
break;

Expand Down

0 comments on commit 385317a

Please sign in to comment.