summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-07-18 17:11:38 -0400
committerGitHub <noreply@github.com>2020-07-18 17:11:38 -0400
commitd7f78c23b50218eaa52ab4570a1e2297c52c287e (patch)
tree64a217ccc1f96efeec3c81e1d16215963536c733 /ext/bg/js/backend.js
parente696dc84a857e60adcfa7feec44398765c430cac (diff)
Script ready state change (#672)
* Update how backend/frontend ready states are awaited and signaled * Log errors on the search page * Update action name
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 301fe135..854c64d6 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -85,7 +85,7 @@ class Backend {
this._logErrorLevel = null;
this._messageHandlers = new Map([
- ['yomichanCoreReady', {async: false, contentScript: true, handler: this._onApiYomichanCoreReady.bind(this)}],
+ ['requestBackendReadySignal', {async: false, contentScript: true, handler: this._onApiRequestBackendReadySignal.bind(this)}],
['optionsSchemaGet', {async: false, contentScript: true, handler: this._onApiOptionsSchemaGet.bind(this)}],
['optionsGet', {async: false, contentScript: true, handler: this._onApiOptionsGet.bind(this)}],
['optionsGetFull', {async: false, contentScript: true, handler: this._onApiOptionsGetFull.bind(this)}],
@@ -212,9 +212,9 @@ class Backend {
this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this));
- this._sendMessageAllTabs('backendPrepared');
+ this._sendMessageAllTabs('backendReady');
const callback = () => this._checkLastError(chrome.runtime.lastError);
- chrome.runtime.sendMessage({action: 'backendPrepared'}, callback);
+ chrome.runtime.sendMessage({action: 'backendReady'}, callback);
} catch (e) {
yomichan.logError(e);
throw e;
@@ -361,10 +361,10 @@ class Backend {
// Message handlers
- _onApiYomichanCoreReady(_params, sender) {
+ _onApiRequestBackendReadySignal(_params, sender) {
// tab ID isn't set in background (e.g. browser_action)
const callback = () => this._checkLastError(chrome.runtime.lastError);
- const data = {action: 'backendPrepared'};
+ const data = {action: 'backendReady'};
if (typeof sender.tab === 'undefined') {
chrome.runtime.sendMessage(data, callback);
return false;
@@ -1393,7 +1393,7 @@ class Backend {
sender.tab.id !== tabId ||
sender.frameId !== frameId ||
!isObject(message) ||
- message.action !== 'yomichanCoreReady'
+ message.action !== 'yomichanReady'
) {
return;
}