aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/backend.js12
-rw-r--r--ext/bg/js/context-main.js4
-rw-r--r--ext/bg/js/search-main.js4
-rw-r--r--ext/bg/js/settings/main.js62
4 files changed, 46 insertions, 36 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;
}
diff --git a/ext/bg/js/context-main.js b/ext/bg/js/context-main.js
index 6d17dbf7..14013d3f 100644
--- a/ext/bg/js/context-main.js
+++ b/ext/bg/js/context-main.js
@@ -76,7 +76,7 @@ async function setupOptions() {
(async () => {
api.forwardLogsToBackend();
- await yomichan.ready();
+ await yomichan.backendReady();
const manifest = chrome.runtime.getManifest();
@@ -87,4 +87,6 @@ async function setupOptions() {
setupButtonEvents('.action-open-search', 'search', chrome.runtime.getURL('/bg/search.html'));
setupButtonEvents('.action-open-options', 'options', chrome.runtime.getURL(manifest.options_ui.page));
setupButtonEvents('.action-open-help', 'help', 'https://foosoft.net/projects/yomichan/');
+
+ yomichan.ready();
})();
diff --git a/ext/bg/js/search-main.js b/ext/bg/js/search-main.js
index bbe6c343..cf9282fd 100644
--- a/ext/bg/js/search-main.js
+++ b/ext/bg/js/search-main.js
@@ -23,10 +23,12 @@
(async () => {
try {
api.forwardLogsToBackend();
- await yomichan.ready();
+ await yomichan.backendReady();
const displaySearch = new DisplaySearch();
await displaySearch.prepare();
+
+ yomichan.ready();
} catch (e) {
yomichan.logError(e);
}
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index 48b72735..db371d37 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -63,45 +63,51 @@ async function setupEnvironmentInfo() {
(async () => {
- api.forwardLogsToBackend();
- await yomichan.ready();
+ try {
+ api.forwardLogsToBackend();
+ await yomichan.backendReady();
- setupEnvironmentInfo();
- showExtensionInformation();
- settingsPopulateModifierKeys();
+ setupEnvironmentInfo();
+ showExtensionInformation();
+ settingsPopulateModifierKeys();
- const optionsFull = await api.optionsGetFull();
+ const optionsFull = await api.optionsGetFull();
- const settingsController = new SettingsController(optionsFull.profileCurrent);
- settingsController.prepare();
+ const settingsController = new SettingsController(optionsFull.profileCurrent);
+ settingsController.prepare();
- const storageController = new StorageController();
- storageController.prepare();
+ const storageController = new StorageController();
+ storageController.prepare();
- const genericSettingController = new GenericSettingController(settingsController);
- genericSettingController.prepare();
+ const genericSettingController = new GenericSettingController(settingsController);
+ genericSettingController.prepare();
- const clipboardPopupsController = new ClipboardPopupsController(settingsController);
- clipboardPopupsController.prepare();
+ const clipboardPopupsController = new ClipboardPopupsController(settingsController);
+ clipboardPopupsController.prepare();
- const popupPreviewController = new PopupPreviewController(settingsController);
- popupPreviewController.prepare();
+ const popupPreviewController = new PopupPreviewController(settingsController);
+ popupPreviewController.prepare();
- const audioController = new AudioController(settingsController);
- audioController.prepare();
+ const audioController = new AudioController(settingsController);
+ audioController.prepare();
- const profileController = new ProfileController(settingsController);
- profileController.prepare();
+ const profileController = new ProfileController(settingsController);
+ profileController.prepare();
- const dictionaryController = new DictionaryController(settingsController, storageController);
- dictionaryController.prepare();
+ const dictionaryController = new DictionaryController(settingsController, storageController);
+ dictionaryController.prepare();
- const ankiController = new AnkiController(settingsController);
- ankiController.prepare();
+ const ankiController = new AnkiController(settingsController);
+ ankiController.prepare();
- const ankiTemplatesController = new AnkiTemplatesController(settingsController, ankiController);
- ankiTemplatesController.prepare();
+ const ankiTemplatesController = new AnkiTemplatesController(settingsController, ankiController);
+ ankiTemplatesController.prepare();
- const settingsBackup = new SettingsBackup(settingsController);
- settingsBackup.prepare();
+ const settingsBackup = new SettingsBackup(settingsController);
+ settingsBackup.prepare();
+
+ yomichan.ready();
+ } catch (e) {
+ yomichan.logError(e);
+ }
})();