Check if objects are properly initialized before showing content
This commit is contained in:
parent
8a1637f6b3
commit
a5b208fb89
@ -79,6 +79,10 @@ class Popup {
|
||||
});
|
||||
}
|
||||
|
||||
isInitialized() {
|
||||
return this.options !== null;
|
||||
}
|
||||
|
||||
async setOptions(options) {
|
||||
this.options = options;
|
||||
}
|
||||
@ -212,6 +216,7 @@ class Popup {
|
||||
}
|
||||
|
||||
async showOrphaned(elementRect, writingMode, options) {
|
||||
if (!this.isInitialized()) { return; }
|
||||
await this.show(elementRect, writingMode, options);
|
||||
this.invokeApi('orphaned');
|
||||
}
|
||||
@ -275,11 +280,13 @@ class Popup {
|
||||
}
|
||||
|
||||
async termsShow(elementRect, writingMode, definitions, options, context) {
|
||||
if (!this.isInitialized()) { return; }
|
||||
await this.show(elementRect, writingMode, options);
|
||||
this.invokeApi('termsShow', {definitions, options, context});
|
||||
}
|
||||
|
||||
async kanjiShow(elementRect, writingMode, definitions, options, context) {
|
||||
if (!this.isInitialized()) { return; }
|
||||
await this.show(elementRect, writingMode, options);
|
||||
this.invokeApi('kanjiShow', {definitions, options, context});
|
||||
}
|
||||
|
@ -187,6 +187,10 @@ class Display {
|
||||
throw new Error('Override me');
|
||||
}
|
||||
|
||||
isInitialized() {
|
||||
return this.options !== null;
|
||||
}
|
||||
|
||||
async initialize(options=null) {
|
||||
await this.updateOptions(options);
|
||||
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
|
||||
@ -236,6 +240,8 @@ class Display {
|
||||
}
|
||||
|
||||
async termsShow(definitions, options, context) {
|
||||
if (!this.isInitialized()) { return; }
|
||||
|
||||
try {
|
||||
this.setEventListenersActive(false);
|
||||
|
||||
@ -287,6 +293,8 @@ class Display {
|
||||
}
|
||||
|
||||
async kanjiShow(definitions, options, context) {
|
||||
if (!this.isInitialized()) { return; }
|
||||
|
||||
try {
|
||||
this.setEventListenersActive(false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user