using server.method() instead of direct call to $.ajax - preparation for electron without network requests

This commit is contained in:
azivner
2017-11-28 20:52:38 -05:00
parent 14001f67d8
commit 54c0ff15b3
17 changed files with 150 additions and 217 deletions

View File

@@ -1,21 +1,16 @@
"use strict";
function syncNow() {
$.ajax({
url: baseApiUrl + 'sync/now',
type: 'POST',
success: result => {
if (result.success) {
showMessage("Sync finished successfully.");
}
else {
if (result.message.length > 50) {
result.message = result.message.substr(0, 50);
}
async function syncNow() {
const result = await server.post('sync/now');
showError("Sync failed: " + result.message);
}
},
error: () => showError("Sync failed for unknown reason.")
});
if (result.success) {
showMessage("Sync finished successfully.");
}
else {
if (result.message.length > 50) {
result.message = result.message.substr(0, 50);
}
showError("Sync failed: " + result.message);
}
}