aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-25 04:17:17 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-04-05 19:57:37 +0300
commitc171503d77bbae21ddfa2eb49c6a571440f41763 (patch)
tree00d9f928505c6d26b0fc4167caee3696273949cf /ext/mixed/js
parent7928c5d71324b3eebece7e2a26e9783e139066d5 (diff)
use getTemporaryListenerResult in other places
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/core.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 616f48b8..ca37a26a 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -278,11 +278,16 @@ const yomichan = (() => {
constructor() {
super();
- this._isBackendPreparedResolve = null;
- this._isBackendPreparedPromise = new Promise((resolve) => (this._isBackendPreparedResolve = resolve));
+ this._isBackendPreparedPromise = this.getTemporaryListenerResult(
+ chrome.runtime.onMessage,
+ ({action}, {resolve}) => {
+ if (action === 'backendPrepared') {
+ resolve();
+ }
+ }
+ );
this._messageHandlers = new Map([
- ['backendPrepared', this._onBackendPrepared.bind(this)],
['getUrl', this._onMessageGetUrl.bind(this)],
['optionsUpdated', this._onMessageOptionsUpdated.bind(this)],
['zoomChanged', this._onMessageZoomChanged.bind(this)]
@@ -362,10 +367,6 @@ const yomichan = (() => {
return false;
}
- _onBackendPrepared() {
- this._isBackendPreparedResolve();
- }
-
_onMessageGetUrl() {
return {url: window.location.href};
}