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
chrome.tabs.onUpdated.addListener((tabId, info) => {
// ignore non-complete status
if (info.status !== "complete") {
return;
}
// unregister any auth listeners for this tab
if (authListeners[tabId]) {
chrome.webRequest.onAuthRequired.removeListener(authListeners[tabId]);
delete authListeners[tabId];
if (info.status === "complete") {
if (authListeners[tabId]) {
chrome.webRequest.onAuthRequired.removeListener(authListeners[tabId]);
delete authListeners[tabId];
}
}
// show number of matching passwords in a badge
updateMatchingPasswordsCount(tabId);
// refresh badge counter when url in a tab changes
if (info.url) {
updateMatchingPasswordsCount(tabId);
}
});
// handle incoming messages