From 39d21c3d29ad3507281e258d4539dfe4ef4ba124 Mon Sep 17 00:00:00 2001 From: eight Date: Sat, 13 Oct 2018 23:57:45 +0800 Subject: [PATCH] Fix: broadcastError -> ignoreError --- background/background.js | 4 ++-- content/apply.js | 6 +++++- js/msg.js | 10 +++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/background/background.js b/background/background.js index c7fa7ed0..f42168c5 100644 --- a/background/background.js +++ b/background/background.js @@ -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); } } }); diff --git a/content/apply.js b/content/apply.js index f131a1db..a17ee2f7 100644 --- a/content/apply.js +++ b/content/apply.js @@ -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}) { diff --git a/js/msg.js b/js/msg.js index 5c372005..d6c0cb35 100644 --- a/js/msg.js +++ b/js/msg.js @@ -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) {