mirror of https://github.com/gorhill/uBlock.git
logger: do not regenerate whole tab selector if no change
This commit is contained in:
parent
92be1c2a12
commit
ea4f4cee72
|
@ -136,6 +136,7 @@ return {
|
|||
selfieAfter: 23 * oneMinute,
|
||||
|
||||
pageStores: {},
|
||||
pageStoresToken: 0,
|
||||
|
||||
storageQuota: vAPI.storage.QUOTA_BYTES,
|
||||
storageUsed: 0,
|
||||
|
|
|
@ -48,7 +48,7 @@ var lastVarDataIndex = 4; // currently, d0-d3
|
|||
var maxEntries = 5000;
|
||||
var noTabId = '';
|
||||
var allTabIds = {};
|
||||
|
||||
var allTabIdsToken;
|
||||
var hiddenTemplate = document.querySelector('#hiddenTemplate > span');
|
||||
|
||||
var prettyRequestTypes = {
|
||||
|
@ -347,10 +347,6 @@ var renderLogEntries = function(response) {
|
|||
|
||||
var synchronizeTabIds = function(newTabIds) {
|
||||
var oldTabIds = allTabIds;
|
||||
|
||||
// Neuter rows for which a tab does not exist anymore
|
||||
// TODO: sort to avoid using indexOf
|
||||
|
||||
var autoDeleteVoidRows = !!vAPI.localStorage.getItem('loggerAutoDeleteVoidRows');
|
||||
var rowVoided = false;
|
||||
var trs;
|
||||
|
@ -443,8 +439,12 @@ var onLogBufferRead = function(response) {
|
|||
}
|
||||
|
||||
// Neuter rows for which a tab does not exist anymore
|
||||
// TODO: sort to avoid using indexOf
|
||||
var rowVoided = synchronizeTabIds(response.tabIds);
|
||||
var rowVoided = false;
|
||||
if ( response.tabIdsToken !== allTabIdsToken ) {
|
||||
rowVoided = synchronizeTabIds(response.tabIds);
|
||||
allTabIdsToken = response.tabIdsToken;
|
||||
}
|
||||
|
||||
renderLogEntries(response);
|
||||
|
||||
if ( rowVoided ) {
|
||||
|
|
|
@ -1210,7 +1210,8 @@ var onMessage = function(request, sender, callback) {
|
|||
entries: µb.logger.readAll(),
|
||||
maxEntries: µb.userSettings.requestLogMaxEntries,
|
||||
noTabId: vAPI.noTabId,
|
||||
tabIds: tabIds
|
||||
tabIds: tabIds,
|
||||
tabIdsToken: µb.pageStoresToken
|
||||
};
|
||||
break;
|
||||
|
||||
|
|
|
@ -523,6 +523,8 @@ vAPI.tabs.registerListeners();
|
|||
|
||||
// Tab is not bound
|
||||
if ( !pageStore ) {
|
||||
this.updateTitle(tabId);
|
||||
this.pageStoresToken = Date.now();
|
||||
return this.pageStores[tabId] = this.PageStore.factory(tabId);
|
||||
}
|
||||
|
||||
|
@ -538,13 +540,14 @@ vAPI.tabs.registerListeners();
|
|||
return pageStore;
|
||||
}
|
||||
|
||||
this.updateTitle(tabId);
|
||||
|
||||
// Rebind according to context. We rebind even if the URL did not change,
|
||||
// as maybe the tab was force-reloaded, in which case the page stats must
|
||||
// be all reset.
|
||||
pageStore.reuse(context);
|
||||
|
||||
this.updateTitle(tabId);
|
||||
this.pageStoresToken = Date.now();
|
||||
|
||||
return pageStore;
|
||||
};
|
||||
|
||||
|
@ -556,6 +559,7 @@ vAPI.tabs.registerListeners();
|
|||
if ( pageStore !== undefined ) {
|
||||
pageStore.dispose();
|
||||
delete this.pageStores[tabId];
|
||||
this.pageStoresToken = Date.now();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -605,11 +609,18 @@ vAPI.tabs.registerListeners();
|
|||
if ( pageStore === null ) {
|
||||
return tryNoMore(tabId);
|
||||
}
|
||||
// Firefox needs this: if you detach a tab, the new tab won't have
|
||||
// its rawURL set. Concretely, this causes the logger to report an
|
||||
// entry to itself in the logger's tab selector.
|
||||
// TODO: Investigate for a fix vAPI-side.
|
||||
pageStore.rawURL = tab.url;
|
||||
this.pageStoresToken = Date.now();
|
||||
if ( !tab.title && tryAgain(tabId) ) {
|
||||
return;
|
||||
}
|
||||
tryNoMore(tabId);
|
||||
pageStore.title = tab.title || tab.url || '';
|
||||
this.pageStoresToken = Date.now();
|
||||
};
|
||||
|
||||
var updateTitle = function(tabId) {
|
||||
|
|
Loading…
Reference in New Issue