Index: lib/init.js |
=================================================================== |
--- a/lib/init.js |
+++ b/lib/init.js |
@@ -1,8 +1,26 @@ |
+var _prefsInitDone = false; |
+var _filtersInitDone = false; |
+ |
+require("prefs").Prefs._initListener = function() |
+{ |
+ _prefsInitDone = true; |
+ _checkInitialized(); |
+}; |
+ |
+function _checkInitialized() |
+{ |
+ if (_prefsInitDone && _filtersInitDone) |
+ { |
+ _checkInitialized = function() {}; |
+ _triggerEvent("init"); |
+ } |
+} |
+ |
require("filterNotifier").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 |
@@ -22,11 +40,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(); |
} |
}); |