From 2c7b8800b7085c755dee14af5765e9f519aa0a9e Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 15 Sep 2014 14:28:07 -0400 Subject: [PATCH] this fixes #234 --- js/storage.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/js/storage.js b/js/storage.js index 5bfaa5e17..e25bc82fd 100644 --- a/js/storage.js +++ b/js/storage.js @@ -442,26 +442,27 @@ // revisited. µBlock.reloadPresetBlacklists = function(switches, update) { - var presetBlacklists = this.remoteBlacklists; + var µb = µBlock; + + var onFilterListsReady = function() { + µb.loadUpdatableAssets({ update: update, psl: update }); + }; // Toggle switches, if any if ( switches !== undefined ) { + var filterLists = this.remoteBlacklists; var i = switches.length; while ( i-- ) { - if ( !presetBlacklists[switches[i].location] ) { + if ( filterLists.hasOwnProperty(switches[i].location) === false ) { continue; } - presetBlacklists[switches[i].location].off = !!switches[i].off; + filterLists[switches[i].location].off = !!switches[i].off; } - // Save switch states - chrome.storage.local.set({ 'remoteBlacklists': presetBlacklists }, function() { - µBlock.getBytesInUse(); - }); + chrome.storage.local.set({ 'remoteBlacklists': filterLists }, onFilterListsReady); + } else { + onFilterListsReady(); } - - // Now force reload - this.loadUpdatableAssets({ update: update, psl: update }); }; /******************************************************************************/