aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-08-23 15:18:41 -0400
committerGitHub <noreply@github.com>2020-08-23 15:18:41 -0400
commit773e28aa3c23c1cb93d5b19b10c49fcec19487a9 (patch)
treefcf3c775c3f97d1852848253149a47b55fa0a753 /ext/mixed/js/display.js
parent934355dd09aa8b7e8993759b678af063b56b9fc6 (diff)
Fix screenshot popup hide (#753)
* Refactor Popup.setVisibleOverride * Use event to observe visibility changes * Add setAllVisibleOverride/clearAllVisibleOverride * Add setAllVisibleOverride/clearAllVisibleOverride cross frame handlers * Update how visibility is changed * Wait for next frame to ensure visibility has been updated
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index c3498e85..6e41a190 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -1145,9 +1145,12 @@ class Display extends EventDispatcher {
}
async _getScreenshot() {
+ const ownerFrameId = this._ownerFrameId;
+ let token = null;
try {
- await this._setPopupVisibleOverride(false);
- await promiseTimeout(1); // Wait for popup to be hidden.
+ if (ownerFrameId !== null) {
+ token = await api.crossFrame.invoke(ownerFrameId, 'setAllVisibleOverride', {value: false, priority: 0, awaitFrame: true});
+ }
const {format, quality} = this._options.anki.screenshot;
const dataUrl = await api.screenshotGet({format, quality});
@@ -1155,7 +1158,9 @@ class Display extends EventDispatcher {
return {dataUrl, format};
} finally {
- await this._setPopupVisibleOverride(null);
+ if (token !== null) {
+ await api.crossFrame.invoke(ownerFrameId, 'clearAllVisibleOverride', {token});
+ }
}
}
@@ -1163,10 +1168,6 @@ class Display extends EventDispatcher {
return this._options.general.resultOutputMode === 'merge' ? 0 : -1;
}
- _setPopupVisibleOverride(visible) {
- return api.broadcastTab('popupSetVisibleOverride', {visible});
- }
-
_getEntry(index) {
const entries = this._container.querySelectorAll('.entry');
return index >= 0 && index < entries.length ? entries[index] : null;