Merge pull request #187 from toasted-nutbread/suppress-runtime-lasterror-messages

Suppress messages about unchecked runtime.lastError
This commit is contained in:
Alex Yatskov 2019-08-26 17:26:30 -07:00 committed by GitHub
commit 7bf215617c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -57,9 +57,10 @@ class Backend {
this.anki = new AnkiNull();
}
const callback = () => this.checkLastError(chrome.runtime.lastError);
chrome.tabs.query({}, tabs => {
for (const tab of tabs) {
chrome.tabs.sendMessage(tab.id, {action: 'optionsSet', params: options}, () => null);
chrome.tabs.sendMessage(tab.id, {action: 'optionsSet', params: options}, callback);
}
});
}
@ -147,6 +148,10 @@ class Backend {
chrome.browserAction.setBadgeText({text});
}
}
checkLastError(e) {
// NOP
}
}
window.yomichan_backend = new Backend();

View File

@ -27,6 +27,7 @@ function utilInvoke(action, params={}) {
return new Promise((resolve, reject) => {
try {
chrome.runtime.sendMessage({action, params}, (response) => {
utilCheckLastError(chrome.runtime.lastError);
if (response !== null && typeof response === 'object') {
if (response.error) {
reject(response.error);
@ -43,3 +44,7 @@ function utilInvoke(action, params={}) {
}
});
}
function utilCheckLastError(e) {
// NOP
}