From a07a8dfff667e0bba20d7199c4d7aa610e98bcdb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 3 Jul 2020 12:20:22 -0400 Subject: Extension unload detection (#647) * Update how extension unload is detected * Remove event handlers and use yomichan.isExtensionUnloaded instead * Update terminology --- ext/fg/js/frontend.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'ext/fg/js/frontend.js') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index f6b0d236..33cb0b90 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -32,7 +32,6 @@ class Frontend { this._options = null; this._pageZoomFactor = 1.0; this._contentScale = 1.0; - this._orphaned = false; this._lastShowPromise = Promise.resolve(); this._enabledEventListeners = new EventListenerCollection(); this._activeModifiers = new Set(); @@ -110,7 +109,6 @@ class Frontend { visualViewport.addEventListener('resize', this._onVisualViewportResize.bind(this)); } - yomichan.on('orphaned', this._onOrphaned.bind(this)); yomichan.on('optionsUpdated', this.updateOptions.bind(this)); yomichan.on('zoomChanged', this._onZoomChanged.bind(this)); chrome.runtime.onMessage.addListener(this._onRuntimeMessage.bind(this)); @@ -230,10 +228,6 @@ class Frontend { return false; } - _onOrphaned() { - this._orphaned = true; - } - _onZoomChanged({newZoomFactor}) { this._pageZoomFactor = newZoomFactor; this._updateContentScale(); @@ -370,9 +364,9 @@ class Frontend { } } } catch (e) { - if (this._orphaned) { + if (yomichan.isExtensionUnloaded) { if (textSource !== null && this._options.scanning.modifier !== 'none') { - this._showPopupContent(textSource, await this.getOptionsContext(), 'orphaned'); + this._showPopupContent(textSource, await this.getOptionsContext(), 'extensionUnloaded'); } } else { yomichan.logError(e); -- cgit v1.2.3