fix: avoid to modify stored charging profiles
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 8 Jun 2024 19:36:07 +0000 (21:36 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 8 Jun 2024 19:36:07 +0000 (21:36 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/Helpers.ts

index 2c264cd5612cfbeb8d1ccf01347e06810fcabf0d..74b5e2afd2147996c3ac5b591729559d65bf0503 100644 (file)
@@ -636,15 +636,14 @@ export const getConnectorChargingProfiles = (
   chargingStation: ChargingStation,
   connectorId: number
 ): ChargingProfile[] => {
-  return clone<ChargingProfile[]>(
-    (chargingStation.getConnectorStatus(connectorId)?.chargingProfiles ?? [])
-      .sort((a, b) => b.stackLevel - a.stackLevel)
-      .concat(
-        (chargingStation.getConnectorStatus(0)?.chargingProfiles ?? []).sort(
-          (a, b) => b.stackLevel - a.stackLevel
-        )
-      )
-  )
+  return (chargingStation.getConnectorStatus(connectorId)?.chargingProfiles ?? [])
+    .slice()
+    .sort((a, b) => b.stackLevel - a.stackLevel)
+    .concat(
+      (chargingStation.getConnectorStatus(0)?.chargingProfiles ?? [])
+        .slice()
+        .sort((a, b) => b.stackLevel - a.stackLevel)
+    )
 }
 
 export const getChargingStationConnectorChargingProfilesPowerLimit = (