From 443a47b38789526625751602087042fd56f3e9c3 Mon Sep 17 00:00:00 2001 From: Mari Date: Fri, 9 Jul 2021 16:14:05 -0400 Subject: [PATCH] Make the failure action from the server send a list of IDs with the same failure reason. --- client/src/actions/NetworkAction.ts | 5 ++++- client/src/reducers/ServerReducer.ts | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/actions/NetworkAction.ts b/client/src/actions/NetworkAction.ts index 84d8b97..3a806e6 100644 --- a/client/src/actions/NetworkAction.ts +++ b/client/src/actions/NetworkAction.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 diff --git a/client/src/reducers/ServerReducer.ts b/client/src/reducers/ServerReducer.ts index 637cde5..b057a58 100644 --- a/client/src/reducers/ServerReducer.ts +++ b/client/src/reducers/ServerReducer.ts @@ -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])