diff options
author | Darius Jahandarie <djahandarie@gmail.com> | 2023-10-22 23:34:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-22 23:34:48 +0000 |
commit | c3148c6cf0522c5a3b3f3db6e495f401050c73f7 (patch) | |
tree | 22d68f73f998241a8e0fa922727509349007e1da /ext/js/data | |
parent | 7039438ce5087ba4236a81b197ee8c3bfd5164d2 (diff) | |
parent | 757707539690b6aec45e9de8cd37fdfc907d8843 (diff) |
Merge pull request #276 from praschke/block-helper-rewrite
Block helper rewrite
Diffstat (limited to 'ext/js/data')
-rw-r--r-- | ext/js/data/options-util.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 2674701f..1f2ffb05 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -470,7 +470,8 @@ class OptionsUtil { {async: false, update: this._updateVersion17.bind(this)}, {async: false, update: this._updateVersion18.bind(this)}, {async: false, update: this._updateVersion19.bind(this)}, - {async: false, update: this._updateVersion20.bind(this)} + {async: false, update: this._updateVersion20.bind(this)}, + {async: true, update: this._updateVersion21.bind(this)} ]; if (typeof targetVersion === 'number' && targetVersion < result.length) { result.splice(targetVersion); @@ -997,4 +998,36 @@ class OptionsUtil { } return options; } + + async _updateVersion21(options) { + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v21.handlebars'); + + let customTemplates = false; + for (const {options: profileOptions} of options.profiles) { + if (profileOptions.anki.fieldTemplates !== null) { + customTemplates = true; + } + } + + if (customTemplates && isObject(chrome.storage)) { + chrome.storage.session.set({'needsCustomTemplatesWarning': true}); + await this._createTab(chrome.runtime.getURL('/welcome.html')); + chrome.storage.session.set({'openedWelcomePage': true}); + } + + return options; + } + + _createTab(url) { + return new Promise((resolve, reject) => { + chrome.tabs.create({url}, (tab) => { + const e = chrome.runtime.lastError; + if (e) { + reject(new Error(e.message)); + } else { + resolve(tab); + } + }); + }); + } } |