Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
this fixes #226
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Sep 11, 2014
1 parent 7089c4d commit ab508b8
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
publicSuffixList: publicSuffixList.toSelfie(),
filterLists: this.remoteBlacklists,
netFilteringEngine: this.netFilteringEngine.toSelfie(),
cosmeticFilteringEngine: this.cosmeticFilteringEngine.toSelfie(),
cosmeticFilteringEngine: this.cosmeticFilteringEngine.toSelfie()
};
chrome.storage.local.set({ selfie: selfie });
// console.log('µBlock.toSelfie> made a selfie!');
Expand Down Expand Up @@ -582,9 +582,10 @@

µBlock.load = function() {
var µb = this;
var fromSelfie = false;

// Final initialization steps after all needed assets are in memory
var onAllDone = function(wasAutoUpdated) {
var onAllDone = function() {
// Initialize internal state with maybe already existing tabs
var bindToTabs = function(tabs) {
var scriptStart = function(tabId) {
Expand Down Expand Up @@ -615,26 +616,37 @@
// https://github.com/gorhill/uBlock/issues/184
// If we restored a selfie, check for updates not too far
// in the future.
µb.updater.restart(wasAutoUpdated ? µb.nextUpdateAfter : µb.firstUpdateAfter);
var nextUpdate = fromSelfie === false && µb.userSettings.autoUpdate ?
µb.nextUpdateAfter :
µb.firstUpdateAfter;
µb.updater.restart(nextUpdate);
};

// Filters are in memory
// https://github.com/gorhill/uBlock/issues/226
// Whitelist in memory.
// Whitelist parser needs PSL to be ready.
var onWhitelistReady = function() {
onAllDone();
};

// Filters are in memory.
// Filter engines need PSL to be ready.
var onFiltersReady = function() {
onAllDone(µb.userSettings.autoUpdate);
µb.loadWhitelist(onWhitelistReady);
};

// Load order because dependencies:
// User settings -> PSL -> [filter lists, user whitelist]
var onPSLReady = function() {
µb.loadWhitelist();
µb.loadFilterLists(onFiltersReady);
};

// If no selfie available, take the long way, i.e. load and parse
// raw data.
var onSelfieReady = function(success) {
if ( success === true ) {
onAllDone(false);
fromSelfie = true;
µb.loadWhitelist(onWhitelistReady);
return;
}
µb.assets.autoUpdate = µb.userSettings.autoUpdate;
Expand Down

0 comments on commit ab508b8

Please sign in to comment.