From 52748e2c6d0b08cecaa3e626f615c92ba6bbf758 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 5 Feb 2021 21:52:56 +0100 Subject: [PATCH] Remove uneeded intermediate variable. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/OCPPRequestService.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 6b19d061..6ebb4e38 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -24,7 +24,6 @@ export default abstract class OCPPRequestService { public async sendMessage(messageId: string, commandParams: any, messageType: MessageType = MessageType.CALL_RESULT_MESSAGE, commandName: RequestCommand | IncomingRequestCommand): Promise { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; - const chargingStation = this.chargingStation; // Send a message through wsConnection return new Promise((resolve: (value?: any | PromiseLike) => void, reject: (reason?: any) => void) => { let messageToSend: string; @@ -71,8 +70,8 @@ export default abstract class OCPPRequestService { // Function that will receive the request's response async function responseCallback(payload: Record | string, requestPayload: Record): Promise { - if (chargingStation.getEnableStatistics()) { - chargingStation.statistics.addMessage(commandName, messageType); + if (self.chargingStation.getEnableStatistics()) { + self.chargingStation.statistics.addMessage(commandName, messageType); } // Send the response await self.ocppResponseService.handleResponse(commandName as RequestCommand, payload, requestPayload); @@ -81,13 +80,13 @@ export default abstract class OCPPRequestService { // Function that will receive the request's rejection function rejectCallback(error: OCPPError): void { - if (chargingStation.getEnableStatistics()) { - chargingStation.statistics.addMessage(commandName, messageType); + if (self.chargingStation.getEnableStatistics()) { + self.chargingStation.statistics.addMessage(commandName, messageType); } - logger.debug(`${chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams); + logger.debug(`${self.chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams); // Build Exception // eslint-disable-next-line no-empty-function - chargingStation.requests[messageId] = [() => { }, () => { }, {}]; // Properly format the request + self.chargingStation.requests[messageId] = [() => { }, () => { }, {}]; // Send error reject(error); } -- 2.34.1