fix Yomichan core message issues

This commit is contained in:
siikamiika 2020-03-02 10:35:46 +02:00
parent 967e99b7f6
commit bd48d2f919
3 changed files with 6 additions and 3 deletions

View File

@ -48,7 +48,7 @@ class Backend {
this.messageToken = yomichan.generateId(16); this.messageToken = yomichan.generateId(16);
this._messageHandlers = new Map([ this._messageHandlers = new Map([
['yomichanOnline', this._onApiYomichanOnline.bind(this)], ['yomichanCoreReady', this._onApiYomichanCoreReady.bind(this)],
['optionsSchemaGet', this._onApiOptionsSchemaGet.bind(this)], ['optionsSchemaGet', this._onApiOptionsSchemaGet.bind(this)],
['optionsGet', this._onApiOptionsGet.bind(this)], ['optionsGet', this._onApiOptionsGet.bind(this)],
['optionsGetFull', this._onApiOptionsGetFull.bind(this)], ['optionsGetFull', this._onApiOptionsGetFull.bind(this)],
@ -273,7 +273,7 @@ class Backend {
// Message handlers // Message handlers
async _onApiYomichanOnline(_params, sender) { async _onApiYomichanCoreReady(_params, sender) {
const tabId = sender.tab.id; const tabId = sender.tab.id;
return new Promise((resolve) => { return new Promise((resolve) => {
chrome.tabs.sendMessage(tabId, {action: 'backendPrepared'}, resolve); chrome.tabs.sendMessage(tabId, {action: 'backendPrepared'}, resolve);

View File

@ -280,7 +280,7 @@ const yomichan = (() => {
]); ]);
chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); chrome.runtime.onMessage.addListener(this._onMessage.bind(this));
chrome.runtime.sendMessage({action: 'yomichanOnline'}); chrome.runtime.sendMessage({action: 'yomichanCoreReady'});
} }
// Public // Public

View File

@ -30,6 +30,9 @@ const chrome = {
}, },
getURL(path2) { getURL(path2) {
return url.pathToFileURL(path.join(__dirname, '..', 'ext', path2.replace(/^\//, ''))); return url.pathToFileURL(path.join(__dirname, '..', 'ext', path2.replace(/^\//, '')));
},
sendMessage() {
// NOP
} }
} }
}; };