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

Unified Diff: lib/init.js

Issue 10802049: Functional prefs implementation (Closed)
Patch Set: Created June 5, 2013, 9:03 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
« no previous file with comments | « lib/api.js ('k') | lib/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
});
« no previous file with comments | « lib/api.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld