Skip to content

Commit 284602d

Browse files
committed
refactor: rimossa esecuzione hooks se finestra senza focus
1 parent 1d476fc commit 284602d

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

assets/src/js/functions/hooks.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,22 @@ function handleHooksSuccess(hooks) {
8383
}
8484

8585
function startHooks() {
86-
$.ajax({
87-
url: globals.rootdir + "/ajax.php",
88-
type: "get",
89-
data: {
90-
op: "hooks",
91-
},
92-
success: function (data) {
93-
hooks = JSON.parse(data);
94-
handleHooksSuccess(hooks);
95-
},
96-
error: function (xhr, status, error) {
97-
console.error("Errore durante la richiesta AJAX relativa agli Hooks");
98-
}
99-
});
86+
if (document.hasFocus()) {
87+
$.ajax({
88+
url: globals.rootdir + "/ajax.php",
89+
type: "get",
90+
data: {
91+
op: "hooks",
92+
},
93+
success: function (data) {
94+
hooks = JSON.parse(data);
95+
handleHooksSuccess(hooks);
96+
},
97+
error: function (xhr, status, error) {
98+
console.error("Errore durante la richiesta AJAX relativa agli Hooks");
99+
}
100+
});
101+
}
100102
}
101103

102104
var timeout = 600;

0 commit comments

Comments
 (0)