summaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-12 20:32:46 -0500
committerGitHub <noreply@github.com>2020-11-12 20:32:46 -0500
commitf2ad94e54f2a110bf93aebfae33c808c497005be (patch)
tree82580173f795f09e40fbc47f0e8877e24b751160 /ext/fg/js/popup.js
parent219dfb4917f5b19da19b85ff223de663db561fe7 (diff)
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
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js18
1 files changed, 9 insertions, 9 deletions
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);
+ }
}