Perf bugfix: reduce number of times badge counter is refreshed (#136)

This commit is contained in:
Maxim Baz
2019-04-25 10:05:11 +02:00
committed by GitHub
parent 150e342522
commit bf1ead6032

View File

@@ -34,19 +34,18 @@ chrome.browserAction.setBadgeBackgroundColor({
// watch for tab updates // watch for tab updates
chrome.tabs.onUpdated.addListener((tabId, info) => { chrome.tabs.onUpdated.addListener((tabId, info) => {
// ignore non-complete status
if (info.status !== "complete") {
return;
}
// unregister any auth listeners for this tab // unregister any auth listeners for this tab
if (authListeners[tabId]) { if (info.status === "complete") {
chrome.webRequest.onAuthRequired.removeListener(authListeners[tabId]); if (authListeners[tabId]) {
delete authListeners[tabId]; chrome.webRequest.onAuthRequired.removeListener(authListeners[tabId]);
delete authListeners[tabId];
}
} }
// show number of matching passwords in a badge // refresh badge counter when url in a tab changes
updateMatchingPasswordsCount(tabId); if (info.url) {
updateMatchingPasswordsCount(tabId);
}
}); });
// handle incoming messages // handle incoming messages