Revert "Revert "Use Q instead of Task.spawn to run processUpdatedXML()""

This reverts commit 4334260865.
This commit is contained in:
Dan Stillman 2014-06-20 03:20:35 -04:00
parent 4334260865
commit 09e53d85d5
2 changed files with 10 additions and 5 deletions

View file

@ -1627,9 +1627,7 @@ Zotero.Sync.Server = new function () {
_error(e); _error(e);
} }
Components.utils.import("resource://gre/modules/Task.jsm"); Q.async(Zotero.Sync.Server.Data.processUpdatedXML(
Task.spawn(Zotero.Sync.Server.Data.processUpdatedXML(
responseNode.getElementsByTagName('updated')[0], responseNode.getElementsByTagName('updated')[0],
lastLocalSyncDate, lastLocalSyncDate,
syncSession, syncSession,
@ -1838,7 +1836,7 @@ Zotero.Sync.Server = new function () {
Zotero.HTTP.doPost(url, body, uploadCallback); Zotero.HTTP.doPost(url, body, uploadCallback);
} }
} }
)) ))()
.then( .then(
null, null,
function (e) { function (e) {

View file

@ -1021,7 +1021,14 @@ function async(makeGenerator) {
} }
return when(result, callback, errback); 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 callback = continuer.bind(continuer, "send");
var errback = continuer.bind(continuer, "throw"); var errback = continuer.bind(continuer, "throw");
return callback(); return callback();