From 09e53d85d5a33668e091387b1871072ca8b32259 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 20 Jun 2014 03:20:35 -0400 Subject: [PATCH] Revert "Revert "Use Q instead of Task.spawn to run processUpdatedXML()"" This reverts commit 433426086567f9c79e86d8b857b4ef444e2e1081. --- chrome/content/zotero/xpcom/sync.js | 6 ++---- resource/q.js | 9 ++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 4f0901d1d0..ae10eb5a8b 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1627,9 +1627,7 @@ Zotero.Sync.Server = new function () { _error(e); } - Components.utils.import("resource://gre/modules/Task.jsm"); - - Task.spawn(Zotero.Sync.Server.Data.processUpdatedXML( + Q.async(Zotero.Sync.Server.Data.processUpdatedXML( responseNode.getElementsByTagName('updated')[0], lastLocalSyncDate, syncSession, @@ -1838,7 +1836,7 @@ Zotero.Sync.Server = new function () { Zotero.HTTP.doPost(url, body, uploadCallback); } } - )) + ))() .then( null, function (e) { diff --git a/resource/q.js b/resource/q.js index 47b3118c2f..de32ab3923 100644 --- a/resource/q.js +++ b/resource/q.js @@ -1021,7 +1021,14 @@ function async(makeGenerator) { } return when(result, callback, errback); } - var generator = makeGenerator.apply(this, arguments); + // Added by Dan + // If already a generator, use that + if (makeGenerator.send) { + var generator = makeGenerator; + } + else { + var generator = makeGenerator.apply(this, arguments); + } var callback = continuer.bind(continuer, "send"); var errback = continuer.bind(continuer, "throw"); return callback();