Rallentamento esecuzione hooks

This commit is contained in:
loviuz 2023-03-10 11:33:19 +01:00
parent 78db635ea9
commit 7c0a8ecbf7
1 changed files with 32 additions and 24 deletions

View File

@ -56,33 +56,41 @@ function startHooks() {
* @param hook * @param hook
*/ */
function startHook(hook, init) { function startHook(hook, init) {
$.ajax({ if (document.hasFocus()) {
url: globals.rootdir + "/ajax.php", $.ajax({
type: "get", url: globals.rootdir + "/ajax.php",
data: { type: "get",
op: "hook-lock", data: {
id: hook.id, op: "hook-lock",
}, id: hook.id,
success: function (data) { },
var token = JSON.parse(data); success: function (data) {
var token = JSON.parse(data);
if (init) { if (init) {
hookCount("#hooks-counter"); hookCount("#hooks-counter");
updateHook(hook); updateHook(hook);
} }
if (token) { if (token) {
executeHook(hook, token); executeHook(hook, token);
} else { } else {
var timeout = 10; var timeout = 30;
setTimeout(function () { setTimeout(function () {
startHook(hook); startHook(hook);
}, timeout * 1000); }, timeout * 1000);
} }
}, },
}); });
} else {
var timeout = 30;
setTimeout(function () {
startHook(hook);
}, timeout * 1000);
}
} }
/** /**
@ -108,7 +116,7 @@ function executeHook(hook, token) {
if (result.execute) { if (result.execute) {
startHook(hook); startHook(hook);
} else { } else {
timeout = 30; timeout = 60;
setTimeout(function () { setTimeout(function () {
startHook(hook); startHook(hook);