Fix: broadcastError -> ignoreError

This commit is contained in:
eight 2018-10-13 23:57:45 +08:00
parent ecb622c93c
commit 39d21c3d29
3 changed files with 12 additions and 8 deletions

View File

@ -92,7 +92,7 @@ navigatorUtil.onUrlChange(({tabId, frameId}, type) => {
return;
}
msg.sendTab(tabId, {method: 'urlChanged'}, {frameId})
.catch(msg.broadcastError);
.catch(msg.ignoreError);
});
if (FIREFOX) {
@ -156,7 +156,7 @@ navigatorUtil.onUrlChange(({tabId, frameId, transitionQualifiers}, type) => {
// `apply.js` doesn't notify the background to update the icon,
// so we have to refresh it manually.
if (transitionQualifiers.includes('forward_back')) {
msg.sendTab(tabId, {method: 'updateCount'}).catch(msg.broadcastError);
msg.sendTab(tabId, {method: 'updateCount'}).catch(msg.ignoreError);
}
}
});

View File

@ -258,6 +258,10 @@ const APPLY = (() => {
// we don't care about iframes
return;
}
if (STYLE_VIA_API) {
API.styleViaAPI({method: 'updateCount'});
return;
}
let count = 0;
for (const id of styleElements.keys()) {
if (!disabledElements.has(id)) {
@ -269,7 +273,7 @@ const APPLY = (() => {
method: 'invokeAPI',
name: 'updateIconBadge',
args: [count]
}).catch(() => {});
}).catch(msg.ignoreError);
}
function applyStyleState({id, enabled}) {

View File

@ -37,7 +37,7 @@ const msg = (() => {
broadcast,
broadcastTab,
broadcastExtension,
broadcastError,
ignoreError,
on,
onTab,
onExtension,
@ -87,7 +87,7 @@ const msg = (() => {
}
}
function broadcastError(err) {
function ignoreError(err) {
if (err.message && (
RX_NO_RECEIVER.test(err.message) ||
RX_PORT_CLOSED.test(err.message)
@ -99,7 +99,7 @@ const msg = (() => {
function broadcast(data, filter) {
return Promise.all([
send(data, 'both').catch(broadcastError),
send(data, 'both').catch(ignoreError),
broadcastTab(data, filter, null, true, 'both')
]);
}
@ -134,14 +134,14 @@ const msg = (() => {
if (message.id) {
request = withCleanup(request, () => bg._msg.storage.delete(message.id));
}
requests.push(request.catch(broadcastError));
requests.push(request.catch(ignoreError));
}
return Promise.all(requests);
});
}
function broadcastExtension(...args) {
return send(...args).catch(broadcastError);
return send(...args).catch(ignoreError);
}
function on(fn) {