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