Skip to content
Permalink
Browse files

Merge branch 'change/58-save-settings-on-default' into 'master'

Save settings on default value loaded

Closes #58

See merge request zwieback/splitterino!47
  • Loading branch information...
prefixaut committed Sep 6, 2019
2 parents 0e7bc75 + 7e824b3 commit b06cc6cc3a3d11cb4a47b1e843fc0d8310b8041c
Showing with 19 additions and 13 deletions.
  1. +19 −13 src/services/io.service.ts
@@ -604,24 +604,30 @@ export class IOService {
plugins: {},
};

if (loadedSettings != null) {
for (const [moduleKey, modulE] of Object.entries(store.state.splitterino.settings.configuration)) {
for (const namespacE of modulE) {
for (const group of namespacE.groups) {
for (const setting of group.settings) {
let value = setting.defaultValue;
const path = `${moduleKey}.${namespacE.key}.${group.key}.${setting.key}`;
if (loadedSettings[path] !== undefined) {
value = loadedSettings[path];
}

set<Settings>(parsedSettings, path, value);
let usedDefaultValue = false;

for (const [moduleKey, modulE] of Object.entries(store.state.splitterino.settings.configuration)) {
for (const namespacE of modulE) {
for (const group of namespacE.groups) {
for (const setting of group.settings) {
let value = setting.defaultValue;
const path = `${moduleKey}.${namespacE.key}.${group.key}.${setting.key}`;
if (loadedSettings != null && loadedSettings[path] !== undefined) {
value = loadedSettings[path];
} else {
usedDefaultValue = true;
}

set<Settings>(parsedSettings, path, value);
}
}
}
}

await store.dispatch(ACTION_SET_ALL_SETTINGS, { values: parsedSettings });

await store.dispatch(ACTION_SET_ALL_SETTINGS, { values: parsedSettings });
if (usedDefaultValue) {
this.saveSettingsToFile(store);
}
}
}

0 comments on commit b06cc6c

Please sign in to comment.
You can’t perform that action at this time.