From f2ad94e54f2a110bf93aebfae33c808c497005be Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 12 Nov 2020 20:32:46 -0500 Subject: Text scanning options propagation (#1020) * Update Display.setOptionsContext to update options * Update how options context is updated in Popup * Omit optionsContext for some _showPopupContent calls * Remove extension unload * Disable modifier keys in frontend's options context * Update how text scanner passes modifiers to options context * Update how options context is passed to display * Update how display uses options context --- ext/fg/js/popup.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ext/fg/js/popup.js') diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index ee3bf646..df177289 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -39,7 +39,6 @@ class Popup extends EventDispatcher { this._optionsContext = null; this._contentScale = 1.0; this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, ''); - this._previousOptionsContextSource = null; this._frameSizeContentScale = null; this._frameClient = null; @@ -105,14 +104,10 @@ class Popup extends EventDispatcher { this._onVisibleChange({value: this.isVisibleSync()}); } - async setOptionsContext(optionsContext, source) { + async setOptionsContext(optionsContext) { this._optionsContext = optionsContext; - this._previousOptionsContextSource = source; - this._options = await api.optionsGet(optionsContext); this.updateTheme(); - - this._invokeSafe('setOptionsContext', {optionsContext}); } hide(changeFocus) { @@ -154,9 +149,9 @@ class Popup extends EventDispatcher { async showContent(details, displayDetails) { if (this._options === null) { throw new Error('Options not assigned'); } - const {source, optionsContext, elementRect, writingMode} = details; - if (typeof source !== 'undefined' && source !== this._previousOptionsContextSource) { - await this.setOptionsContext(optionsContext, source); + const {optionsContext, elementRect, writingMode} = details; + if (optionsContext !== null) { + await this._setOptionsContextIfDifferent(optionsContext); } if (typeof elementRect !== 'undefined' && typeof writingMode !== 'undefined') { @@ -659,4 +654,9 @@ class Popup extends EventDispatcher { bottom: window.innerHeight }; } + + async _setOptionsContextIfDifferent(optionsContext) { + if (deepEqual(this._optionsContext, optionsContext)) { return; } + await this.setOptionsContext(optionsContext); + } } -- cgit v1.2.3