diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-11 21:31:21 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-11 21:31:21 -0500 |
commit | f287d686245371ee3ef8483d1027f06c30dc6a5e (patch) | |
tree | 8a61cff7b59826b3a42712ce4eb54dfec4184bbe | |
parent | 99867ebdd8ddc168abc3cc796a0c6a23701b2235 (diff) |
Add showContentCompleted for improved semantic clarity
-rw-r--r-- | ext/bg/js/settings/popup-preview-frame.js | 2 | ||||
-rw-r--r-- | ext/fg/js/frontend.js | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index dc85f493..9f642681 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -166,7 +166,7 @@ class SettingsPopupPreview { source.cleanup(); } this.textSource = source; - await this.frontend.lastShowPromise; + await this.frontend.showContentCompleted(); if (this.frontend.popup.isVisible()) { this.popupShown = true; diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 01f5c13d..54e78bf5 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -37,7 +37,7 @@ class Frontend extends TextScanner { this.isPreparedPromiseResolve = null; this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; }); - this.lastShowPromise = Promise.resolve(); + this._lastShowPromise = Promise.resolve(); } static create() { @@ -68,7 +68,7 @@ class Frontend extends TextScanner { async onResize() { const textSource = this.textSourceCurrent; if (textSource !== null && await this.popup.isVisibleAsync()) { - this.lastShowPromise = this.popup.showContent( + this._lastShowPromise = this.popup.showContent( textSource.getRect(), textSource.getWritingMode() ); @@ -124,7 +124,7 @@ class Frontend extends TextScanner { } catch (e) { if (window.yomichan_orphaned) { if (textSource !== null && this.options.scanning.modifier !== 'none') { - this.lastShowPromise = this.popup.showContent( + this._lastShowPromise = this.popup.showContent( textSource.getRect(), textSource.getWritingMode(), 'orphaned' @@ -145,7 +145,7 @@ class Frontend extends TextScanner { showContent(textSource, focus, definitions, type) { const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt); const url = window.location.href; - this.lastShowPromise = this.popup.showContent( + this._lastShowPromise = this.popup.showContent( textSource.getRect(), textSource.getWritingMode(), type, @@ -153,6 +153,10 @@ class Frontend extends TextScanner { ); } + showContentCompleted() { + return this._lastShowPromise; + } + async findTerms(textSource) { this.setTextSourceScanLength(textSource, this.options.scanning.length); |