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) 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; return false;
} }
console.log(group, id);
if (typeof this.groups[group] !== 'undefined') { if (typeof this.groups[group] !== 'undefined') {
this.groups[group][id] = true; this.groups[group][id] = true;
} }
if (!this.hasOutstanding(group)) { if (!this.hasOutstanding(group)) {
// todo if it is route then call dispatcher? // todo if it is route then call dispatcher?
this.callbacks[group].lastRun = Date.now();
this.callbacks[group].func(data); this.callbacks[group].func(data);
if (this.callbacks[group].remove) { if (this.callbacks[group].remove) {
@ -215,7 +218,7 @@
return false; return false;
} }
this.callbacks[group] = {remove: remove, reset: reset, func: callback}; this.callbacks[group] = {remove: remove, reset: reset, func: callback, lastRun: 0};
return true; return true;
}; };

View File

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

View File

@ -200,7 +200,7 @@
} }
if (form.getMethod() !== jsOMS.Message.Request.RequestMethod.GET if (form.getMethod() !== jsOMS.Message.Request.RequestMethod.GET
&& Math.floor(Date.now()) - form.getLastSubmit() < 500 && Math.abs(Date.now() - form.getLastSubmit()) < 500
) { ) {
return; return;
} }