Perf bugfix: reduce number of times badge counter is refreshed (#136)
This commit is contained in:
@@ -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
|
||||||
|
Reference in New Issue
Block a user