1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01: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.
// A time out is used to coalesce adjacent requests to update badge.
µBlock.updateBadgeAsync = (function(){
var µb = µBlock;
µBlock.updateBadgeAsync = (function() {
var µb = µBlock, tabIdToUpdate;
// Cache callback definition, it was a bad idea to define this one inside
// updateBadgeAsync
var updateBadge = function(tabId) {
var pageStore = µb.pageStoreFromTabId(tabId);
var updateBadge = function() {
var pageStore = µb.pageStoreFromTabId(tabIdToUpdate);
if ( pageStore ) {
pageStore.updateBadge();
return;
}
vAPI.setIcon(tabId, 'off', '');
vAPI.setIcon(tabIdToUpdate, 'off', '');
};
var updateBadgeAsync = function(tabId) {
if ( vAPI.isBehindTheSceneTabId(tabId) ) {
return;
}
µb.asyncJobs.add('updateBadge-' + tabId, tabId, updateBadge, 0);
tabIdToUpdate = tabId;
setTimeout(updateBadge, 0);
};
return updateBadgeAsync;