Make the failure action from the server send a list of IDs with the same failure reason.

main
Mari 3 years ago
parent ea4ce1c23f
commit 443a47b387
  1. 5
      client/src/actions/NetworkAction.ts
  2. 6
      client/src/reducers/ServerReducer.ts

@ -69,7 +69,10 @@ export const SERVER_FAILED = "SERVER_FAILED"
/** Sent in response to the client's ClientNestedAction, if it fails and has not been applied to the server map. */
export interface ServerFailedAction extends BaseAction {
readonly type: typeof SERVER_FAILED
readonly failures: readonly ActionFailure[]
/** The IDs of the failed actions, all of which failed with the same error. */
readonly ids: readonly number[]
/** The error the above actions failed with. */
readonly error: string
}
export function isServerFailedAction(action: AppAction): action is ServerFailedAction {
return action.type === SERVER_FAILED

@ -156,10 +156,10 @@ function serverFailedReducer(oldState: AppState, action: ServerFailedAction): Ap
return oldState
}
const failedIndexes: {[id: number]: boolean|undefined} = {}
for (let index = 0; index < action.failures.length; index += 1) {
failedIndexes[action.failures[index].id] = true
for (let index = 0; index < action.ids.length; index += 1) {
failedIndexes[action.ids[index]] = true
}
// TODO: Figure out somewhere to put the failures for logging purposes, so the messages aren't wasted.
// TODO: Figure out somewhere to put the failure message for logging purposes, so the messages aren't wasted.
/* const failedActions = */
oldState.network.sentActions.filter((sent) => !!failedIndexes[sent.id]).map((sent) => sent.action)
const stillWaitingActions = oldState.network.sentActions.filter((sent) => !failedIndexes[sent.id])

Loading…
Cancel
Save