fix Backend prepare issues in settings
This commit is contained in:
parent
bd48d2f919
commit
e0edb30efd
@ -39,6 +39,8 @@ class Backend {
|
|||||||
url: window.location.href
|
url: window.location.href
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.isPrepared = false;
|
||||||
|
|
||||||
this.clipboardPasteTarget = document.querySelector('#clipboard-paste-target');
|
this.clipboardPasteTarget = document.querySelector('#clipboard-paste-target');
|
||||||
|
|
||||||
this.popupWindow = null;
|
this.popupWindow = null;
|
||||||
@ -108,6 +110,8 @@ class Backend {
|
|||||||
}
|
}
|
||||||
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
|
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
|
||||||
|
|
||||||
|
this.isPrepared = true;
|
||||||
|
|
||||||
const options = this.getOptions(this.optionsContext);
|
const options = this.getOptions(this.optionsContext);
|
||||||
if (options.general.showGuide) {
|
if (options.general.showGuide) {
|
||||||
chrome.tabs.create({url: chrome.runtime.getURL('/bg/guide.html')});
|
chrome.tabs.create({url: chrome.runtime.getURL('/bg/guide.html')});
|
||||||
|
@ -362,10 +362,10 @@ async function _onSettingsResetConfirmClick() {
|
|||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
function backupInitialize() {
|
||||||
document.querySelector('#settings-export').addEventListener('click', _onSettingsExportClick, false);
|
document.querySelector('#settings-export').addEventListener('click', _onSettingsExportClick, false);
|
||||||
document.querySelector('#settings-import').addEventListener('click', _onSettingsImportClick, false);
|
document.querySelector('#settings-import').addEventListener('click', _onSettingsImportClick, false);
|
||||||
document.querySelector('#settings-import-file').addEventListener('change', _onSettingsImportFileChange, false);
|
document.querySelector('#settings-import-file').addEventListener('change', _onSettingsImportFileChange, false);
|
||||||
document.querySelector('#settings-reset').addEventListener('click', _onSettingsResetClick, false);
|
document.querySelector('#settings-reset').addEventListener('click', _onSettingsResetClick, false);
|
||||||
document.querySelector('#settings-reset-modal-confirm').addEventListener('click', _onSettingsResetConfirmClick, false);
|
document.querySelector('#settings-reset-modal-confirm').addEventListener('click', _onSettingsResetConfirmClick, false);
|
||||||
}, false);
|
}
|
||||||
|
@ -21,7 +21,7 @@ utilBackend, utilIsolate, utilBackgroundIsolate
|
|||||||
ankiErrorShown, ankiFieldsToDict
|
ankiErrorShown, ankiFieldsToDict
|
||||||
ankiTemplatesUpdateValue, onAnkiOptionsChanged, onDictionaryOptionsChanged
|
ankiTemplatesUpdateValue, onAnkiOptionsChanged, onDictionaryOptionsChanged
|
||||||
appearanceInitialize, audioSettingsInitialize, profileOptionsSetup, dictSettingsInitialize
|
appearanceInitialize, audioSettingsInitialize, profileOptionsSetup, dictSettingsInitialize
|
||||||
ankiInitialize, ankiTemplatesInitialize, storageInfoInitialize
|
ankiInitialize, ankiTemplatesInitialize, storageInfoInitialize, backupInitialize
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getOptionsMutable(optionsContext) {
|
function getOptionsMutable(optionsContext) {
|
||||||
@ -262,6 +262,8 @@ function showExtensionInformation() {
|
|||||||
|
|
||||||
|
|
||||||
async function onReady() {
|
async function onReady() {
|
||||||
|
await yomichan.prepare();
|
||||||
|
|
||||||
showExtensionInformation();
|
showExtensionInformation();
|
||||||
|
|
||||||
formSetupEventListeners();
|
formSetupEventListeners();
|
||||||
@ -271,6 +273,7 @@ async function onReady() {
|
|||||||
await dictSettingsInitialize();
|
await dictSettingsInitialize();
|
||||||
ankiInitialize();
|
ankiInitialize();
|
||||||
ankiTemplatesInitialize();
|
ankiTemplatesInitialize();
|
||||||
|
backupInitialize();
|
||||||
|
|
||||||
storageInfoInitialize();
|
storageInfoInitialize();
|
||||||
|
|
||||||
|
@ -73,7 +73,11 @@ function utilStringHashCode(string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function utilBackend() {
|
function utilBackend() {
|
||||||
return chrome.extension.getBackgroundPage().yomichanBackend;
|
const backend = chrome.extension.getBackgroundPage().yomichanBackend;
|
||||||
|
if (!backend.isPrepared) {
|
||||||
|
throw new Error('Backend not ready yet');
|
||||||
|
}
|
||||||
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function utilAnkiGetModelNames() {
|
async function utilAnkiGetModelNames() {
|
||||||
|
Loading…
Reference in New Issue
Block a user