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
*/
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);
});
});
}

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 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;
}