Index: lib/init.js |
=================================================================== |
--- a/lib/init.js |
+++ b/lib/init.js |
@@ -1,5 +1,32 @@ |
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 |
+ // with default settings |
+ let {Subscription, DownloadableSubscription} = require("subscriptionClasses"); |
+ let {Synchronizer} = require("synchronizer"); |
+ let {Prefs} = require("prefs"); |
+ let {Utils} = require("utils"); |
+ |
+ // Choose default subscription and add it |
+ let subscriptions = require("subscriptions.xml"); |
+ let node = Utils.chooseFilterSubscription(subscriptions); |
+ if (node) |
+ { |
+ let subscription = Subscription.fromURL(node.url); |
+ FilterStorage.addSubscription(subscription); |
+ subscription.disabled = false; |
+ subscription.title = node.title; |
+ subscription.homepage = node.homepage; |
+ if (subscription instanceof DownloadableSubscription && !subscription.lastDownload) |
+ Synchronizer.execute(subscription); |
+ } |
+ } |
+ |
_triggerEvent("init"); |
+ } |
}); |