From eb9bb8ab818ddeb73a05b17752571ee0145e48b4 Mon Sep 17 00:00:00 2001 From: petemill Date: Mon, 27 Aug 2018 11:19:33 -0700 Subject: [PATCH] Set shields badge count for active tab only Fix https://github.com/brave/brave-browser/issues/743 --- app/background/api/browserActionAPI.ts | 7 +++++-- app/background/reducers/shieldsPanelReducer.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/background/api/browserActionAPI.ts b/app/background/api/browserActionAPI.ts index 55f06ca..b6a02aa 100644 --- a/app/background/api/browserActionAPI.ts +++ b/app/background/api/browserActionAPI.ts @@ -29,9 +29,12 @@ export function init () { * Sets the badge text * @param {string} text - The text to put on the badge */ -export const setBadgeText = (text: string) => { +export const setBadgeText = (tabId: number, text: string) => { if (chrome.browserAction) { - chrome.browserAction.setBadgeText({ text: String(text) }) + chrome.browserAction.setBadgeText({ + tabId, + text: String(text) + }) } } diff --git a/app/background/reducers/shieldsPanelReducer.ts b/app/background/reducers/shieldsPanelReducer.ts index 11dfbd9..829976f 100644 --- a/app/background/reducers/shieldsPanelReducer.ts +++ b/app/background/reducers/shieldsPanelReducer.ts @@ -30,7 +30,7 @@ const updateBadgeText = (state: State) => { if (tab) { const total = tab.adsBlocked + tab.trackersBlocked + tab.javascriptBlocked + tab.fingerprintingBlocked + tab.httpsRedirected // do not show any badge if there are no blocked items - setBadgeText(total > 99 ? '99+' : total > 0 ? total.toString() : '') + setBadgeText(tabId, total > 99 ? '99+' : total > 0 ? total.toString() : '') } }