X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FUIServiceWorkerBroadcastChannel.ts;h=7e4cc87720f81e10dacb625c00ed1474a821260d;hb=5566ca3ebbfc761e2b4538be722399628f34a87b;hp=a2b209220ae084ba84e1fa7accda1e782443929b;hpb=5e3cb7281de2b6fa8b61a453f964c2f213fefa80;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/UIServiceWorkerBroadcastChannel.ts index a2b20922..7e4cc877 100644 --- a/src/charging-station/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/UIServiceWorkerBroadcastChannel.ts @@ -29,7 +29,7 @@ export default class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChan } private responseHandler(messageEvent: MessageEvent): void { - if (this.isRequest(messageEvent.data)) { + if (this.isRequest(messageEvent.data) === true) { return; } const [uuid, responsePayload] = this.validateMessageEvent(messageEvent) @@ -41,16 +41,14 @@ export default class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChan responses: [responsePayload], }); } else if ( - this.responses.get(uuid)?.responsesReceived + 1 < - this.responses.get(uuid)?.responsesExpected + this.responses.get(uuid)?.responsesReceived <= this.responses.get(uuid)?.responsesExpected ) { this.responses.get(uuid).responsesReceived++; this.responses.get(uuid).responses.push(responsePayload); - } else if ( - this.responses.get(uuid)?.responsesReceived + 1 === - this.responses.get(uuid)?.responsesExpected + } + if ( + this.responses.get(uuid)?.responsesReceived === this.responses.get(uuid)?.responsesExpected ) { - this.responses.get(uuid).responses.push(responsePayload); this.uiService.sendResponse(uuid, this.buildResponsePayload(uuid)); this.responses.delete(uuid); this.uiService.deleteBroadcastChannelRequest(uuid); @@ -83,6 +81,16 @@ export default class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChan }) .filter((hashId) => hashId !== undefined), }), + ...(responsesStatus === ResponseStatus.FAILURE && { + responsesFailed: this.responses + .get(uuid) + ?.responses.map((response) => { + if (response.status === ResponseStatus.FAILURE) { + return response; + } + }) + .filter((response) => response !== undefined), + }), }; }