From dbdcd51331c1eca37d5bf9ba8a9e0857ec8c1293 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 14 Mar 2022 10:03:31 +0100 Subject: [PATCH] Simplify default settings at configuration key adding 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 | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) 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 { -- 2.34.1