diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-20 13:44:33 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-20 13:44:33 -0500 |
commit | 2519f99f54412933beed8b2c753c76662099f8e0 (patch) | |
tree | 4fc453e375394749ad1cd5d1e1fb72cafef84048 /ext/fg/js/frontend.js | |
parent | 2a95f1420f08b034ae8e12ecffed86aa6f33e53a (diff) |
Update how orphan state is observed
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r-- | ext/fg/js/frontend.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 1d63d928..6b41138f 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -37,6 +37,7 @@ class Frontend extends TextScanner { this.isPreparedPromiseResolve = null; this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; }); + this._orphaned = true; this._lastShowPromise = Promise.resolve(); } @@ -54,6 +55,7 @@ class Frontend extends TextScanner { try { await this.updateOptions(); + yomichan.on('orphaned', () => this.onOrphaned()); yomichan.on('optionsUpdate', () => this.updateOptions()); chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); this.isPreparedPromiseResolve(); @@ -93,6 +95,10 @@ class Frontend extends TextScanner { return false; } + onOrphaned() { + this._orphaned = true; + } + getMouseEventListeners() { return [ ...super.getMouseEventListeners(), @@ -122,7 +128,7 @@ class Frontend extends TextScanner { } } } catch (e) { - if (window.yomichan_orphaned) { + if (this._orphaned) { if (textSource !== null && this.options.scanning.modifier !== 'none') { this._lastShowPromise = this.popup.showContent( textSource.getRect(), |