From e9e43cff1ad9ba7f75e3ae64a53fceb596454a59 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 5 Feb 2024 11:57:51 +0100 Subject: [PATCH] fix: add charging station at instantiation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 4 +++- src/charging-station/ChargingStationWorker.ts | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c8eaf5e4..0f4bce43 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -245,6 +245,8 @@ export class ChargingStation extends EventEmitter { this.initialize() + this.add() + this.stationInfo?.autoStart === true && this.start() } @@ -652,7 +654,7 @@ export class ChargingStation extends EventEmitter { } } - public add (): void { + private add (): void { this.emit(ChargingStationEvents.added) } diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index 4eb6e6a0..4fde42c4 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -19,8 +19,8 @@ export let chargingStationWorker: object if (Configuration.workerPoolInUse()) { chargingStationWorker = new ThreadWorker( (data?: ChargingStationWorkerData): void => { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - new ChargingStation(data!.index, data!.templateFile).add() + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, no-new + new ChargingStation(data!.index, data!.templateFile) } ) } else { @@ -35,7 +35,6 @@ if (Configuration.workerPoolInUse()) { message.data.index, message.data.templateFile ) - chargingStation.add() parentPort?.postMessage({ event: WorkerMessageEvents.addedWorkerElement, data: buildChargingStationDataPayload(chargingStation) -- 2.34.1