Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/init.js

Issue 10802049: Functional prefs implementation (Closed)
Patch Set: Cleaned up init.js a bit Created June 5, 2013, 9:44 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}
});

Powered by Google App Engine
This is Rietveld