aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display-generator.js26
-rw-r--r--ext/mixed/js/display.js11
2 files changed, 7 insertions, 30 deletions
diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js
index d5ab9dbc..ee3ac4cf 100644
--- a/ext/mixed/js/display-generator.js
+++ b/ext/mixed/js/display-generator.js
@@ -19,9 +19,6 @@
class DisplayGenerator {
constructor() {
- this._isInitialized = false;
- this._initializationPromise = null;
-
this._termEntryTemplate = null;
this._termExpressionTemplate = null;
this._termDefinitionItemTemplate = null;
@@ -40,18 +37,10 @@ class DisplayGenerator {
this._tagFrequencyTemplate = null;
}
- isInitialized() {
- return this._isInitialized;
- }
-
- initialize() {
- if (this._isInitialized) {
- return Promise.resolve();
- }
- if (this._initializationPromise === null) {
- this._initializationPromise = this._initializeInternal();
- }
- return this._initializationPromise;
+ async prepare() {
+ const html = await apiGetDisplayTemplatesHtml();
+ const doc = new DOMParser().parseFromString(html, 'text/html');
+ this._setTemplates(doc);
}
createTermEntry(details) {
@@ -303,13 +292,6 @@ class DisplayGenerator {
return node;
}
- async _initializeInternal() {
- const html = await apiGetDisplayTemplatesHtml();
- const doc = new DOMParser().parseFromString(html, 'text/html');
- this._setTemplates(doc);
- this._isInitialized = true;
- }
-
_setTemplates(doc) {
this._termEntryTemplate = doc.querySelector('#term-entry-template');
this._termExpressionTemplate = doc.querySelector('#term-expression-template');
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index a6cfe848..cee63d9b 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -243,6 +243,7 @@ class Display {
}
async initialize(options=null) {
+ await this.displayGenerator.prepare();
await this.updateOptions(options);
yomichan.on('optionsUpdate', () => this.updateOptions(null));
}
@@ -365,10 +366,7 @@ class Display {
window.focus();
}
- if (!this.displayGenerator.isInitialized()) {
- await this.displayGenerator.initialize();
- if (this.setContentToken !== token) { return; }
- }
+ if (this.setContentToken !== token) { return; }
this.definitions = definitions;
if (context.disableHistory) {
@@ -429,10 +427,7 @@ class Display {
window.focus();
}
- if (!this.displayGenerator.isInitialized()) {
- await this.displayGenerator.initialize();
- if (this.setContentToken !== token) { return; }
- }
+ if (this.setContentToken !== token) { return; }
this.definitions = definitions;
if (context.disableHistory) {