From a5b208fb895d46793223910451d177dc53d9463a Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 12 Oct 2019 14:41:24 -0400 Subject: Check if objects are properly initialized before showing content --- ext/mixed/js/display.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ext/mixed/js') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 0d7be355..d5d055e0 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -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); -- cgit v1.2.3