Fix minor bugs and double submit leak

This commit is contained in:
Dennis Eichhorn 2018-07-30 21:51:09 +02:00
parent edc596aba2
commit 3f9b035f4d
3 changed files with 9 additions and 7 deletions

View File

@ -111,16 +111,19 @@
*/
trigger (group, id = '', data = null)
{
if (!this.callbacks.hasOwnProperty(group)) {
if (!this.callbacks.hasOwnProperty(group) || Math.abs(Date.now() - this.callbacks[group].lastRun) < 500) {
return false;
}
console.log(group, id);
if (typeof this.groups[group] !== 'undefined') {
this.groups[group][id] = true;
}
if (!this.hasOutstanding(group)) {
// todo if it is route then call dispatcher?
this.callbacks[group].lastRun = Date.now();
this.callbacks[group].func(data);
if (this.callbacks[group].remove) {
@ -215,7 +218,7 @@
return false;
}
this.callbacks[group] = {remove: remove, reset: reset, func: callback};
this.callbacks[group] = {remove: remove, reset: reset, func: callback, lastRun: 0};
return true;
};

View File

@ -78,7 +78,6 @@
}
let childLength = c.length;
for (let j = 0; j < childLength; ++j) {
this.bindListener(c[j].id, listeners[i]);
}

View File

@ -200,7 +200,7 @@
}
if (form.getMethod() !== jsOMS.Message.Request.RequestMethod.GET
&& Math.floor(Date.now()) - form.getLastSubmit() < 500
&& Math.abs(Date.now() - form.getLastSubmit()) < 500
) {
return;
}
@ -235,10 +235,10 @@
successInject(response);
} else if (typeof response.get(0) !== 'undefined' && typeof response.get(0).type !== 'undefined') {
self.app.responseManager.run(response.get(0).type, response.get(0), request);
}
}
} catch (e) {
console.log(e);
jsOMS.Log.Logger.instance.error('Invalid form response. \n'
+ 'URL: ' + form.getAction() + '\n'
+ 'Request: ' + JSON.stringify(form.getData()) + '\n'
@ -247,7 +247,7 @@
}
});
request.setResultCallback(0, function (xhr)
request.setResultCallback(0, function (xhr)
{
self.app.notifyManager.send(
new jsOMS.Message.Notification.NotificationMessage(