}
private responseHandler(messageEvent: MessageEvent): void {
- if (this.isRequest(messageEvent.data)) {
+ if (this.isRequest(messageEvent.data) === true) {
return;
}
const [uuid, responsePayload] = this.validateMessageEvent(messageEvent)
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);
})
.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),
+ }),
};
}