Bug 686579 - Kick off a sync immediately after setting up Sync on Fennec. r=mfinkle
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Thu, 22 Sep 2011 12:57:54 -0700
changeset 77751 95bee1fc81173cbc194775b0f10778d109db813b
parent 77750 ff0814fd7bbcbd541bb67d261b411082f7cd17f2
child 77752 95bf2ab25e7577c90ce0d33a6e256cba5620a77e
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmfinkle
bugs686579
milestone9.0a1
Bug 686579 - Kick off a sync immediately after setting up Sync on Fennec. r=mfinkle
mobile/chrome/content/sync.js
--- a/mobile/chrome/content/sync.js
+++ b/mobile/chrome/content/sync.js
@@ -302,18 +302,21 @@ let WeaveGlue = {
     this._elements.connect.removeAttribute("desc");
 
     // Reset the custom server URL, if we have one
     if (this.setupData.serverURL && this.setupData.serverURL.length)
       Weave.Service.serverURL = this.setupData.serverURL;
 
     // Sync will use the account value and munge it into a username, as needed
     Weave.Service.account = this.setupData.account;
-    Weave.Service.login(Weave.Service.username, this.setupData.password, this.setupData.synckey);
+    Weave.Service.password = this.setupData.password;
+    Weave.Service.passphrase = this.setupData.synckey;
     Weave.Service.persistLogin();
+    Weave.Svc.Obs.notify("weave:service:setup-complete");
+    setTimeout(function () { Weave.Service.sync(); }, 0);
   },
 
   disconnect: function disconnect() {
     // Save credentials for undo
     let undoData = this.setupData;
 
     // Remove all credentials
     this.setupData = null;
@@ -340,17 +343,18 @@ let WeaveGlue = {
     Weave.Service.logout();
   },
 
   sync: function sync() {
     Weave.Service.sync();
   },
 
   _addListeners: function _addListeners() {
-    let topics = ["weave:service:sync:start", "weave:service:sync:finish",
+    let topics = ["weave:service:setup-complete",
+      "weave:service:sync:start", "weave:service:sync:finish",
       "weave:service:sync:error", "weave:service:login:start",
       "weave:service:login:finish", "weave:service:login:error",
       "weave:service:logout:finish"];
 
     // For each topic, add WeaveGlue the observer
     topics.forEach(function(topic) {
       Services.obs.addObserver(WeaveGlue, topic, false);
     });