Remove coroutines from connector-shared code

This commit is contained in:
Adomas Venčkauskas 2016-10-24 11:45:35 +03:00
parent 96e3c2e81c
commit 24709a9c4b
2 changed files with 33 additions and 29 deletions

View File

@ -276,8 +276,8 @@ Zotero.Connector_Debug = new function() {
/** /**
* Call a callback with the lines themselves * Call a callback with the lines themselves
*/ */
this.get = Zotero.Promise.coroutine(function* (callback) { this.get = function(callback) {
callback(yield Zotero.Debug.get()); Zotero.Debug.get().then(callback);
}); });
/** /**
@ -290,29 +290,31 @@ Zotero.Connector_Debug = new function() {
/** /**
* Submit data to the server * Submit data to the server
*/ */
this.submitReport = Zotero.Promise.coroutine(function* (callback) { this.submitReport = function(callback) {
var output = yield Zotero.Debug.get(); Zotero.Debug.get().then(function(output){
var req = yield Zotero.HTTP.request( return Zotero.HTTP.request(
ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1", ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1",
{ {
headers: { headers: {
"Content-Type": "text/plain" "Content-Type": "text/plain"
}, },
body: output, body: output,
successCodes: false successCodes: false
}
);
}).then(function(xmlhttp){
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;
} }
);
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'); var reportID = reported[0].getAttribute('reportID');
callback(true, reportID); callback(true, reportID);
});
}); });
} }

View File

@ -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 output = _output;
var total = output.length; var total = output.length;
@ -158,11 +158,13 @@ Zotero.Debug = new function () {
} }
} }
if(Zotero.getErrors) { if (Zotero.getErrors) {
return Zotero.getErrors(true).join('\n\n') + return Zotero.getSystemInfo().then(function(sysInfo) {
"\n\n" + (yield Zotero.getSystemInfo()) + "\n\n" + return Zotero.getErrors(true).join('\n\n') +
"\n\n" + sysInfo + "\n\n" +
"=========================================================\n\n" + "=========================================================\n\n" +
output; output;
});
} else { } else {
return output; return output;
} }