aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-07 15:59:10 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-10 20:09:33 -0400
commit4686a31a0a5d30a1b01e3cd2b689d1950c79c940 (patch)
tree89c2cd502e98f432591cd66790c877a94b1cee64 /ext
parent99cec1d23fc779ae26112dcd63d86b5f6fa4bddd (diff)
Use apiOptionsGet instead of optionsLoad
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/context.js3
-rw-r--r--ext/bg/js/settings.js27
2 files changed, 22 insertions, 8 deletions
diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js
index 689d6863..dfa224a7 100644
--- a/ext/bg/js/context.js
+++ b/ext/bg/js/context.js
@@ -22,7 +22,8 @@ $(document).ready(utilAsync(() => {
$('#open-options').click(() => apiCommandExec('options'));
$('#open-help').click(() => apiCommandExec('help'));
- optionsLoad().then(options => {
+ const optionsContext = {depth: 0};
+ apiOptionsGet(optionsContext).then(options => {
const toggle = $('#enable-search');
toggle.prop('checked', options.general.enable).change();
toggle.bootstrapToggle();
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index a59f7c0d..1c9198dd 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+function getOptionsContext() {
+ return {
+ depth: 0
+ };
+}
async function formRead(options) {
options.general.showGuide = $('#show-usage-guide').prop('checked');
@@ -137,7 +142,8 @@ async function onFormOptionsChanged(e) {
return;
}
- const options = await optionsLoad();
+ const optionsContext = getOptionsContext();
+ const options = await apiOptionsGet(optionsContext);
const optionsAnkiEnableOld = options.anki.enable;
const optionsAnkiServerOld = options.anki.server;
@@ -163,7 +169,8 @@ async function onFormOptionsChanged(e) {
}
async function onReady() {
- const options = await optionsLoad();
+ const optionsContext = getOptionsContext();
+ const options = await apiOptionsGet(optionsContext);
$('#show-usage-guide').prop('checked', options.general.showGuide);
$('#compact-tags').prop('checked', options.general.compactTags);
@@ -374,7 +381,8 @@ async function onDictionaryPurge(e) {
dictionarySpinnerShow(true);
await utilDatabasePurge();
- const options = await optionsLoad();
+ const optionsContext = getOptionsContext();
+ const options = await apiOptionsGet(optionsContext);
options.dictionaries = {};
options.general.mainDictionary = '';
await optionsSave(options);
@@ -414,8 +422,9 @@ async function onDictionaryImport(e) {
setProgress(0.0);
const exceptions = [];
- const options = await optionsLoad();
const summary = await utilDatabaseImport(e.target.files[0], updateProgress, exceptions);
+ const optionsContext = getOptionsContext();
+ const options = await apiOptionsGet(optionsContext);
options.dictionaries[summary.title] = {enabled: true, priority: 0, allowSecondarySearches: false};
if (summary.sequenced && options.general.mainDictionary === '') {
options.general.mainDictionary = summary.title;
@@ -566,7 +575,8 @@ async function onAnkiModelChanged(e) {
const tab = element.closest('.tab-pane');
const tabId = tab.attr('id');
- const options = await optionsLoad();
+ const optionsContext = getOptionsContext();
+ const options = await apiOptionsGet(optionsContext);
await formRead(options);
options.anki[tabId].fields = {};
await optionsSave(options);
@@ -584,8 +594,11 @@ async function onAnkiModelChanged(e) {
async function onAnkiFieldTemplatesReset(e) {
try {
e.preventDefault();
- const options = await optionsLoad();
- $('#field-templates').val(options.anki.fieldTemplates = optionsFieldTemplates());
+ const optionsContext = getOptionsContext();
+ const options = await apiOptionsGet(optionsContext);
+ const fieldTemplates = optionsFieldTemplates();
+ options.anki.fieldTemplates = fieldTemplates;
+ $('#field-templates').val(fieldTemplates);
await optionsSave(options);
} catch (e) {
ankiErrorShow(e);