summaryrefslogtreecommitdiff
path: root/ext/bg/js/options.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/options.js')
-rw-r--r--ext/bg/js/options.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 69c662e6..5f04ec31 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -48,7 +48,7 @@ const optionsVersionUpdates = [
options.scanning.modifier = options.scanning.requireShift ? 'shift' : 'none';
},
(options) => {
- const fieldTemplatesDefault = profileCreateDefaultFieldTemplates();
+ const fieldTemplatesDefault = optionsFieldTemplates();
options.general.resultOutputMode = options.general.groupResults ? 'group' : 'split';
options.anki.fieldTemplates = (
(utilStringHashCode(options.anki.fieldTemplates) !== -805327496) ?
@@ -58,12 +58,12 @@ const optionsVersionUpdates = [
},
(options) => {
if (utilStringHashCode(options.anki.fieldTemplates) === 1285806040) {
- options.anki.fieldTemplates = profileCreateDefaultFieldTemplates();
+ options.anki.fieldTemplates = optionsFieldTemplates();
}
},
(options) => {
if (utilStringHashCode(options.anki.fieldTemplates) === -250091611) {
- options.anki.fieldTemplates = profileCreateDefaultFieldTemplates();
+ options.anki.fieldTemplates = optionsFieldTemplates();
}
}
];
@@ -330,7 +330,7 @@ function optionsLoad() {
}).then(optionsStr => {
if (typeof optionsStr === 'string') {
const options = JSON.parse(optionsStr);
- if (typeof options === 'object' && options !== null && !Array.isArray(options)) {
+ if (utilIsObject(options)) {
return options;
}
}
@@ -343,9 +343,14 @@ function optionsLoad() {
}
function optionsSave(options) {
- return new Promise((resolve) => {
- chrome.storage.local.set({options: JSON.stringify(options)}, resolve);
- }).then(() => {
- utilBackend().onOptionsUpdated(options);
+ return new Promise((resolve, reject) => {
+ chrome.storage.local.set({options: JSON.stringify(options)}, () => {
+ const error = chrome.runtime.lastError;
+ if (error) {
+ reject(error);
+ } else {
+ resolve();
+ }
+ });
});
}