code formatting and cleanup

This commit is contained in:
Yuri Kuznetsov
2020-04-01 16:23:02 +03:00
parent 99af4a6dc7
commit f98810d87f
2 changed files with 30 additions and 31 deletions
+1 -12
View File
@@ -39,20 +39,9 @@ define('ajax', [], function () {
options.data = data;
}
var xhr = $.ajax(options);
return xhr;
var obj = {
then: xhr.then,
fail: xhr.fail,
catch: xhr.fail
};
return obj;
return $.ajax(options);
},
postRequest: function (url, data, options) {
if (data) {
data = JSON.stringify(data);
+29 -19
View File
@@ -206,27 +206,37 @@ define('views/notification/badge', 'view', function (Dep) {
if (!url || !interval) return;
(new Promise(function (resolve) {
if (this.checkBypass()) {
resolve();
return;
}
var jqxhr = Espo.Ajax.getRequest(url).done(function (list) {
list.forEach(function (item) {
this.showPopupNotification(name, item, isNotFirstCheck);
}, this);
}.bind(this));
(new Promise(
function (resolve) {
if (this.checkBypass()) {
resolve();
return;
}
jqxhr.always(function() {
resolve();
});
}.bind(this))).then(function () {
if (useWebSocket) return;
Espo.Ajax.getRequest(url)
.then(
function (list) {
list.forEach(function (item) {
this.showPopupNotification(name, item, isNotFirstCheck);
}, this);
}.bind(this)
)
.always(
function() {
resolve();
}
);
this.popoupTimeouts[name] = setTimeout(function () {
this.checkPopupNotifications(name, isNotFirstCheck);
}.bind(this), interval * 1000);
}.bind(this));
}.bind(this)
)).then(
function () {
if (useWebSocket) return;
this.popoupTimeouts[name] = setTimeout(function () {
this.checkPopupNotifications(name, isNotFirstCheck);
}.bind(this), interval * 1000);
}.bind(this)
);
},
showPopupNotification: function (name, data, isNotFirstCheck) {