summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-10-27 22:43:20 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-10-27 22:43:20 +0200
commit51c35c9f306e48093fc769713675dca5b02d1398 (patch)
tree8c6d81a99442fedfd0f10052488646e2f4fbb305 /ext/bg
parent70418202cf2739258a4e95fdc7f0fbe4c7c46821 (diff)
modify correct profile apiOptionsSet
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/api.js4
-rw-r--r--ext/bg/js/backend.js6
2 files changed, 5 insertions, 5 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 6c109614..95787d7d 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -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);
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 71393467..6d2e736e 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -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;