Index: lib/init.js |
=================================================================== |
--- a/lib/init.js |
+++ b/lib/init.js |
@@ -1,9 +1,30 @@ |
-require("filterNotifier").FilterNotifier.addListener(function(action) |
+let {Prefs} = require("prefs"); |
+let {FilterNotifier} = require("filterNotifier"); |
+ |
+let prefsInitDone = false; |
+let filtersInitDone = false; |
+ |
+function checkInitialized() |
+{ |
+ if (prefsInitDone && filtersInitDone) |
+ { |
+ checkInitialized = function() {}; |
+ _triggerEvent("init"); |
+ } |
+} |
+ |
+Prefs._initListener = function() |
+{ |
+ prefsInitDone = true; |
+ checkInitialized(); |
+}; |
+ |
+FilterNotifier.addListener(function(action) |
{ |
if (action === "load") |
{ |
let {FilterStorage} = require("filterStorage"); |
if (FilterStorage.subscriptions.length == 0) |
{ |
// No data, must be a new user or someone with corrupted data - initialize |
// with default settings |
@@ -22,11 +43,12 @@ require("filterNotifier").FilterNotifier |
subscription.disabled = false; |
subscription.title = node.title; |
subscription.homepage = node.homepage; |
if (subscription instanceof DownloadableSubscription && !subscription.lastDownload) |
Synchronizer.execute(subscription); |
} |
} |
- _triggerEvent("init"); |
+ filtersInitDone = true; |
+ checkInitialized(); |
} |
}); |