Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Simplify default settings at configuration key adding
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
  • Loading branch information
Jérôme Benoit committed Mar 14, 2022
1 parent e80bc57 commit dbdcd51
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/charging-station/ChargingStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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 {
Expand Down

0 comments on commit dbdcd51

Please sign in to comment.