From: Jérôme Benoit Date: Wed, 29 Sep 2021 03:28:41 +0000 (+0200) Subject: Handle connectors number shrinking at template reload. X-Git-Tag: v1.1.17~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=86ad08b201bdfb35de3295a5f36a3998f24ae702;p=e-mobility-charging-stations-simulator.git Handle connectors number shrinking at template reload. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index f93f4133..a5319ecc 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -508,8 +508,9 @@ export default class ChargingStation { this.stationInfo.randomConnectors = true; } const connectorsConfigHash = crypto.createHash('sha256').update(JSON.stringify(this.stationInfo.Connectors) + maxConnectors.toString()).digest('hex'); - // FIXME: Handle shrinking the number of connectors - if (!this.connectors || (this.connectors && this.connectorsConfigurationHash !== connectorsConfigHash)) { + const connectorsConfigChanged = !Utils.isEmptyObject(this.connectors) && this.connectorsConfigurationHash !== connectorsConfigHash; + if (Utils.isEmptyObject(this.connectors) || connectorsConfigChanged) { + connectorsConfigChanged && (this.connectors = {} as Connectors); this.connectorsConfigurationHash = connectorsConfigHash; // Add connector Id 0 let lastConnector = '0';