commit 24709a9c4b35df2bd28a381f2e90cfa6bebc8f06
parent 96e3c2e81cbc3fdf1f6ff26d77e03d0291d25fb6
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date: Mon, 24 Oct 2016 11:45:35 +0300
Remove coroutines from connector-shared code
Diffstat:
2 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/chrome/content/zotero/xpcom/connector/connector.js b/chrome/content/zotero/xpcom/connector/connector.js
@@ -276,8 +276,8 @@ Zotero.Connector_Debug = new function() {
/**
* Call a callback with the lines themselves
*/
- this.get = Zotero.Promise.coroutine(function* (callback) {
- callback(yield Zotero.Debug.get());
+ this.get = function(callback) {
+ Zotero.Debug.get().then(callback);
});
/**
@@ -290,29 +290,31 @@ Zotero.Connector_Debug = new function() {
/**
* Submit data to the server
*/
- this.submitReport = Zotero.Promise.coroutine(function* (callback) {
- var output = yield Zotero.Debug.get();
- var req = yield Zotero.HTTP.request(
- ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1",
- {
- headers: {
- "Content-Type": "text/plain"
- },
- body: output,
- successCodes: false
+ this.submitReport = function(callback) {
+ Zotero.Debug.get().then(function(output){
+ return Zotero.HTTP.request(
+ ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1",
+ {
+ headers: {
+ "Content-Type": "text/plain"
+ },
+ body: output,
+ successCodes: false
+ }
+ );
+ }).then(function(xmlhttp){
+ if (!xmlhttp.responseXML) {
+ callback(false, 'Invalid response from server');
+ return;
}
- );
- if (!xmlhttp.responseXML) {
- callback(false, 'Invalid response from server');
- return;
- }
- var reported = xmlhttp.responseXML.getElementsByTagName('reported');
- if (reported.length != 1) {
- callback(false, 'The server returned an error. Please try again.');
- return;
- }
-
- var reportID = reported[0].getAttribute('reportID');
- callback(true, reportID);
+ var reported = xmlhttp.responseXML.getElementsByTagName('reported');
+ if (reported.length != 1) {
+ callback(false, 'The server returned an error. Please try again.');
+ return;
+ }
+
+ var reportID = reported[0].getAttribute('reportID');
+ callback(true, reportID);
+ });
});
}
diff --git a/chrome/content/zotero/xpcom/debug.js b/chrome/content/zotero/xpcom/debug.js
@@ -129,7 +129,7 @@ Zotero.Debug = new function () {
}
- this.get = Zotero.Promise.coroutine(function* (maxChars, maxLineLength) {
+ this.get = Zotero.Promise.method(function(maxChars, maxLineLength) {
var output = _output;
var total = output.length;
@@ -158,11 +158,13 @@ Zotero.Debug = new function () {
}
}
- if(Zotero.getErrors) {
- return Zotero.getErrors(true).join('\n\n') +
- "\n\n" + (yield Zotero.getSystemInfo()) + "\n\n" +
+ if (Zotero.getErrors) {
+ return Zotero.getSystemInfo().then(function(sysInfo) {
+ return Zotero.getErrors(true).join('\n\n') +
+ "\n\n" + sysInfo + "\n\n" +
"=========================================================\n\n" +
output;
+ });
} else {
return output;
}