modify correct profile apiOptionsSet

This commit is contained in:
siikamiika 2019-10-27 22:43:20 +02:00
parent 70418202cf
commit 51c35c9f30
2 changed files with 5 additions and 5 deletions

View File

@ -23,7 +23,7 @@ function apiOptionsGet(optionsContext) {
async function apiOptionsSet(changedOptions, optionsContext, source) {
const backend = utilBackend();
const {depth} = optionsContext;
const {profileIndex} = backend.getProfileFromContext(optionsContext);
let options = await apiOptionsGetFull();
function getValuePaths(obj) {
@ -63,7 +63,7 @@ async function apiOptionsSet(changedOptions, optionsContext, source) {
}
for (let [value, path] of getValuePaths(changedOptions)) {
modifyOption(path, value, options.profiles[depth].options);
modifyOption(path, value, options.profiles[profileIndex].options);
}
await optionsSave(options);

View File

@ -122,15 +122,15 @@ class Backend {
if (typeof optionsContext.index === 'number') {
return profiles[optionsContext.index];
}
const profile = this.getProfileFromContext(optionsContext);
const {profile} = this.getProfileFromContext(optionsContext);
return profile !== null ? profile : this.options.profiles[this.options.profileCurrent];
}
getProfileFromContext(optionsContext) {
for (const profile of this.options.profiles) {
for (const [profileIndex, profile] of this.options.profiles.entries()) {
const conditionGroups = profile.conditionGroups;
if (conditionGroups.length > 0 && Backend.testConditionGroups(conditionGroups, optionsContext)) {
return profile;
return {profileIndex, profile};
}
}
return null;