Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
fix: disabling a setting with subsettings should be stored
Browse files Browse the repository at this point in the history
this was caused because of the way we checked for a settings key to be available. If the setting would return a falsy value, this would cause the default value to be stored.

fixes #85
  • Loading branch information
Mardaneus86 committed Nov 9, 2017
1 parent 75be510 commit b3ed6b5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/core/settings-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ export class SettingsEntry {
addSetting(label, key, defaultValue, cb) {
const settings = Database.getJson(`settings:${this.id}`, {});

settings[key] = settings[key] ? settings[key] : defaultValue;
settings[key] = key in settings ? settings[key] : defaultValue;
Database.setJson(`settings:${this.id}`, settings);

this.settings.push({
label,
key,
value: settings[key] ? settings[key] : defaultValue,
value: key in settings ? settings[key] : defaultValue,
callback: cb,
subsettings: [],
});
}

addSettingUnder(underKey, label, key, defaultValue, cb) {
const settings = Database.getJson(`settings:${this.id}`, {});
settings[key] = settings[key] ? settings[key] : defaultValue;
settings[key] = key in settings ? settings[key] : defaultValue;
Database.setJson(`settings:${this.id}`, settings);

const setting = this.settings.find(s => s.key === underKey);
setting.subsettings.push({
label,
key,
value: settings[key] ? settings[key] : defaultValue,
value: key in settings ? settings[key] : defaultValue,
callback: cb,
});
}
Expand Down

0 comments on commit b3ed6b5

Please sign in to comment.