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

Side by Side Diff: lib/init.js

Issue 10802049: Functional prefs implementation (Closed)
Patch Set: Created June 5, 2013, 9:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/api.js ('k') | lib/prefs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var _prefsInitDone = false;
2 var _filtersInitDone = false;
3
4 require("prefs").Prefs._initListener = function()
5 {
6 _prefsInitDone = true;
7 _checkInitialized();
8 };
9
10 function _checkInitialized()
11 {
12 if (_prefsInitDone && _filtersInitDone)
13 {
14 _checkInitialized = function() {};
15 _triggerEvent("init");
16 }
17 }
18
1 require("filterNotifier").FilterNotifier.addListener(function(action) 19 require("filterNotifier").FilterNotifier.addListener(function(action)
2 { 20 {
3 if (action === "load") 21 if (action === "load")
4 { 22 {
5 let {FilterStorage} = require("filterStorage"); 23 let {FilterStorage} = require("filterStorage");
6 if (FilterStorage.subscriptions.length == 0) 24 if (FilterStorage.subscriptions.length == 0)
7 { 25 {
8 // No data, must be a new user or someone with corrupted data - initialize 26 // No data, must be a new user or someone with corrupted data - initialize
9 // with default settings 27 // with default settings
10 let {Subscription, DownloadableSubscription} = require("subscriptionClasse s"); 28 let {Subscription, DownloadableSubscription} = require("subscriptionClasse s");
11 let {Synchronizer} = require("synchronizer"); 29 let {Synchronizer} = require("synchronizer");
12 let {Prefs} = require("prefs"); 30 let {Prefs} = require("prefs");
13 let {Utils} = require("utils"); 31 let {Utils} = require("utils");
14 32
15 // Choose default subscription and add it 33 // Choose default subscription and add it
16 let subscriptions = require("subscriptions.xml"); 34 let subscriptions = require("subscriptions.xml");
17 let node = Utils.chooseFilterSubscription(subscriptions); 35 let node = Utils.chooseFilterSubscription(subscriptions);
18 if (node) 36 if (node)
19 { 37 {
20 let subscription = Subscription.fromURL(node.url); 38 let subscription = Subscription.fromURL(node.url);
21 FilterStorage.addSubscription(subscription); 39 FilterStorage.addSubscription(subscription);
22 subscription.disabled = false; 40 subscription.disabled = false;
23 subscription.title = node.title; 41 subscription.title = node.title;
24 subscription.homepage = node.homepage; 42 subscription.homepage = node.homepage;
25 if (subscription instanceof DownloadableSubscription && !subscription.la stDownload) 43 if (subscription instanceof DownloadableSubscription && !subscription.la stDownload)
26 Synchronizer.execute(subscription); 44 Synchronizer.execute(subscription);
27 } 45 }
28 } 46 }
29 47
30 _triggerEvent("init"); 48 _filtersInitDone = true;
49 _checkInitialized();
31 } 50 }
32 }); 51 });
OLDNEW
« 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