aboutsummaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/background/backend.js20
-rw-r--r--ext/js/data/options-util.js27
-rw-r--r--ext/js/pages/welcome-main.js7
3 files changed, 40 insertions, 14 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 565f4abf..755010a3 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -2099,20 +2099,12 @@ class Backend {
}
async _openWelcomeGuidePageOnce() {
- if (isObject(chrome.storage) && isObject(chrome.storage.session)) {
- // Chrome
- chrome.storage.session.get(['openedWelcomePage']).then((result) => {
- if (!result.openedWelcomePage) {
- this._openWelcomeGuidePage();
- chrome.storage.session.set({'openedWelcomePage': true});
- }
- });
- } else {
- // Firefox (storage.session is not supported yet)
- // NOTE: This means that the welcome page will repeatedly open in Firefox
- // until they support storage.session.
- this._openWelcomeGuidePage();
- }
+ chrome.storage.session.get(['openedWelcomePage']).then((result) => {
+ if (!result.openedWelcomePage) {
+ this._openWelcomeGuidePage();
+ chrome.storage.session.set({'openedWelcomePage': true});
+ }
+ });
}
async _openWelcomeGuidePage() {
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js
index 7b050416..1f2ffb05 100644
--- a/ext/js/data/options-util.js
+++ b/ext/js/data/options-util.js
@@ -1001,6 +1001,33 @@ class OptionsUtil {
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);
+ }
+ });
+ });
+ }
}
diff --git a/ext/js/pages/welcome-main.js b/ext/js/pages/welcome-main.js
index 521ce2c2..8039dae5 100644
--- a/ext/js/pages/welcome-main.js
+++ b/ext/js/pages/welcome-main.js
@@ -58,6 +58,13 @@ async function setupGenericSettingsController(genericSettingController) {
setupEnvironmentInfo();
+ chrome.storage.session.get({'needsCustomTemplatesWarning': false}).then((result) => {
+ if (result.needsCustomTemplatesWarning) {
+ document.documentElement.dataset.warnCustomTemplates = 'true';
+ chrome.storage.session.remove(['needsCustomTemplatesWarning']);
+ }
+ });
+
const preparePromises = [];
const modalController = new ModalController();