Skip to content

Commit

Permalink
R Austin review: mark relatedEventInfo non-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Kimmel committed May 18, 2020
1 parent 9e07c11 commit 002d631
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,24 @@ export const dataReducer: Reducer<DataState, ResolverAction> = (state = initialS
};
} else if (action.type === 'userRequestedRelatedEventData') {
const resolverEvent = action.payload;
const statsMap = state.resultsEnrichedWithRelatedEventInfo;
if (statsMap) {
const currentStatsMap = new Map(statsMap);
/**
* Set the waiting indicator for this event to indicate that related event results are pending.
* It will be replaced by the actual results from the API when they are returned.
*/
currentStatsMap.set(resolverEvent, 'waitingForRelatedEventData');
return { ...state, resultsEnrichedWithRelatedEventInfo: currentStatsMap };
}
return state;
const currentStatsMap = new Map(state.resultsEnrichedWithRelatedEventInfo);
/**
* Set the waiting indicator for this event to indicate that related event results are pending.
* It will be replaced by the actual results from the API when they are returned.
*/
currentStatsMap.set(resolverEvent, 'waitingForRelatedEventData');
return { ...state, resultsEnrichedWithRelatedEventInfo: currentStatsMap };
} else if (action.type === 'serverFailedToReturnRelatedEventData') {
const statsMap = state.resultsEnrichedWithRelatedEventInfo;
if (statsMap) {
const currentStatsMap = new Map(statsMap);
const resolverEvent = action.payload;
currentStatsMap.set(resolverEvent, 'error');
return { ...state, resultsEnrichedWithRelatedEventInfo: currentStatsMap };
}
return state;
const currentStatsMap = new Map(state.resultsEnrichedWithRelatedEventInfo);
const resolverEvent = action.payload;
currentStatsMap.set(resolverEvent, 'error');
return { ...state, resultsEnrichedWithRelatedEventInfo: currentStatsMap };
} else if (action.type === 'serverReturnedRelatedEventData') {
const statsMap = state.resultsEnrichedWithRelatedEventInfo;
if (statsMap) {
const relatedDataEntries = new Map([...statsMap, ...action.payload]);
return { ...state, resultsEnrichedWithRelatedEventInfo: relatedDataEntries };
}
return state;
const relatedDataEntries = new Map([
...state.resultsEnrichedWithRelatedEventInfo,
...action.payload,
]);
return { ...state, resultsEnrichedWithRelatedEventInfo: relatedDataEntries };
} else if (action.type === 'appRequestedResolverData') {
return {
...state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export interface DataState {
readonly results: readonly ResolverEvent[];
isLoading: boolean;
hasError: boolean;
resultsEnrichedWithRelatedEventInfo?: Map<ResolverEvent, RelatedEventDataResults>;
resultsEnrichedWithRelatedEventInfo: Map<ResolverEvent, RelatedEventDataResults>;
}

export type Vector2 = readonly [number, number];
Expand Down

0 comments on commit 002d631

Please sign in to comment.