From: Jérôme Benoit Date: Mon, 14 Mar 2022 09:03:31 +0000 (+0100) Subject: Simplify default settings at configuration key adding X-Git-Tag: v1.1.55~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=dbdcd51331c1eca37d5bf9ba8a9e0857ec8c1293;p=e-mobility-charging-stations-simulator.git Simplify default settings at configuration key adding Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index dc679b84..88efd93c 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -625,16 +625,10 @@ export default class ChargingStation { }, params: { overwrite?: boolean; save?: boolean } = { overwrite: false, save: false } ): void { - if (!options || Utils.isEmptyObject(options)) { - options = { - readonly: false, - visible: true, - reboot: false, - }; - } - const readonly = options.readonly ?? false; - const visible = options.visible ?? true; - const reboot = options.reboot ?? false; + options = options ?? ({} as { readonly?: boolean; visible?: boolean; reboot?: boolean }); + options.readonly = options?.readonly ?? false; + options.visible = options?.visible ?? true; + options.reboot = options?.reboot ?? false; let keyFound = this.getConfigurationKey(key); if (keyFound && params?.overwrite) { this.deleteConfigurationKey(keyFound.key, { save: false }); @@ -643,10 +637,10 @@ export default class ChargingStation { if (!keyFound) { this.configuration.configurationKey.push({ key, - readonly, + readonly: options.readonly, value, - visible, - reboot, + visible: options.visible, + reboot: options.reboot, }); params?.save && this.saveConfiguration(); } else {