1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-29 14:17:11 +02:00

Remove icon update coleascing

This commit is contained in:
Chris 2015-05-01 03:22:23 -06:00
parent 0217f1cc8b
commit b9b8f739a0

View File

@ -170,27 +170,27 @@ return asyncJobManager;
/******************************************************************************/ /******************************************************************************/
// Update visual of extension icon. // Update visual of extension icon.
// A time out is used to coalesce adjacent requests to update badge.
µBlock.updateBadgeAsync = (function(){ µBlock.updateBadgeAsync = (function() {
var µb = µBlock; var µb = µBlock, tabIdToUpdate;
// Cache callback definition, it was a bad idea to define this one inside // Cache callback definition, it was a bad idea to define this one inside
// updateBadgeAsync // updateBadgeAsync
var updateBadge = function(tabId) { var updateBadge = function() {
var pageStore = µb.pageStoreFromTabId(tabId); var pageStore = µb.pageStoreFromTabId(tabIdToUpdate);
if ( pageStore ) { if ( pageStore ) {
pageStore.updateBadge(); pageStore.updateBadge();
return; return;
} }
vAPI.setIcon(tabId, 'off', ''); vAPI.setIcon(tabIdToUpdate, 'off', '');
}; };
var updateBadgeAsync = function(tabId) { var updateBadgeAsync = function(tabId) {
if ( vAPI.isBehindTheSceneTabId(tabId) ) { if ( vAPI.isBehindTheSceneTabId(tabId) ) {
return; return;
} }
µb.asyncJobs.add('updateBadge-' + tabId, tabId, updateBadge, 0); tabIdToUpdate = tabId;
setTimeout(updateBadge, 0);
}; };
return updateBadgeAsync; return updateBadgeAsync;