X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fbroadcast-channel%2FUIServiceWorkerBroadcastChannel.ts;h=d328291636ac8da6f37ce6fc1eebca288e67d339;hb=6a4032b5d8f3cbaa18d3beddcdfe9d335c1cba90;hp=d94dfe24be6ffaf34d0b9fad0396f37e4195dc6b;hpb=e1d9a0f4d6ff1a90048e9a694fd12b7031cc6961;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts index d94dfe24..d3282916 100644 --- a/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts +++ b/src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts @@ -24,8 +24,8 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { constructor(uiService: AbstractUIService) { super(); this.uiService = uiService; - this.onmessage = this.responseHandler.bind(this) as (message: MessageEvent) => void; - this.onmessageerror = this.messageErrorHandler.bind(this) as (message: MessageEvent) => void; + this.onmessage = this.responseHandler.bind(this) as (message: unknown) => void; + this.onmessageerror = this.messageErrorHandler.bind(this) as (message: unknown) => void; this.responses = new Map(); } @@ -70,31 +70,31 @@ export class UIServiceWorkerBroadcastChannel extends WorkerBroadcastChannel { status: responsesStatus, hashIdsSucceeded: this.responses .get(uuid) - ?.responses.filter(({ hashId }) => !isNullOrUndefined(hashId)) - .map(({ status, hashId }) => { - if (status === ResponseStatus.SUCCESS) { + ?.responses.map(({ status, hashId }) => { + if (hashId !== undefined && status === ResponseStatus.SUCCESS) { return hashId; } - }) as string[], + }) + .filter((hashId) => !isNullOrUndefined(hashId)) as string[], ...(responsesStatus === ResponseStatus.FAILURE && { hashIdsFailed: this.responses .get(uuid) - ?.responses.filter(({ hashId }) => !isNullOrUndefined(hashId)) - .map(({ status, hashId }) => { - if (status === ResponseStatus.FAILURE) { + ?.responses.map(({ status, hashId }) => { + if (hashId !== undefined && status === ResponseStatus.FAILURE) { return hashId; } - }) as string[], + }) + .filter((hashId) => !isNullOrUndefined(hashId)) as string[], }), ...(responsesStatus === ResponseStatus.FAILURE && { responsesFailed: this.responses .get(uuid) - ?.responses.filter((response) => !isNullOrUndefined(response)) - .map((response) => { - if (response.status === ResponseStatus.FAILURE) { + ?.responses.map((response) => { + if (response !== undefined && response.status === ResponseStatus.FAILURE) { return response; } - }) as BroadcastChannelResponsePayload[], + }) + .filter((response) => !isNullOrUndefined(response)) as BroadcastChannelResponsePayload[], }), }; }