]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix: post updated message on connectorStatusChanged to fix stale UI cache
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 25 Mar 2026 21:20:43 +0000 (22:20 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 25 Mar 2026 21:20:43 +0000 (22:20 +0100)
The .finally() in internalSendMessage emits the updated event BEFORE
sendAndSetConnectorStatus updates connectorStatus.status, causing the
UI cache to snapshot the old status. The connectorStatusChanged event
fires AFTER the update, so posting an updated message on it ensures
the cache receives the correct connector status.

src/charging-station/ChargingStation.ts

index 33d201558d0b313965e6ba7735f80e6007d77ae1..68beff82bfcf0dda52d21abde4d6040f5e4364e3 100644 (file)
@@ -251,6 +251,9 @@ export class ChargingStation extends EventEmitter {
     this.on(ChargingStationEvents.updated, () => {
       parentPort?.postMessage(buildUpdatedMessage(this))
     })
+    this.on(ChargingStationEvents.connectorStatusChanged, () => {
+      parentPort?.postMessage(buildUpdatedMessage(this))
+    })
     this.on(ChargingStationEvents.accepted, () => {
       this.startMessageSequence(
         this.wsConnectionRetryCount > 0