Refactor: Only reload Main/Dash on visibility if Live Updates disabled

This commit is contained in:
Zack Spear
2025-05-05 12:57:39 -07:00
parent 3b982b8399
commit 2edd2b4e51

View File

@@ -411,25 +411,19 @@ $('body').on('click','a,.ca_href', function(e) {
var nchanPaused = false;
var blurTimer = false;
<? if ( $display['liveUpdate'] == "no" ):?>
$(window).focus(function() {
nchanFocusStart();
});
// Stop nchan on loss of focus
<? if ( $display['liveUpdate'] == "no" ):?>
$(window).blur(function() {
blurTimer = setTimeout(function(){
nchanFocusStop();
},30000);
});
<?endif;?>
document.addEventListener("visibilitychange", (event) => {
<? if ( $display['liveUpdate'] == "no" ):?>
if (document.hidden) {
nchanFocusStop();
}
<?else:?>
if (document.hidden) {
nchanFocusStop();
} else {
@@ -445,7 +439,6 @@ document.addEventListener("visibilitychange", (event) => {
nchanFocusStart();
<?endif;?>
}
<?endif;?>
});
function nchanFocusStart() {
@@ -486,4 +479,5 @@ function nchanFocusStop(banner=true) {
}
}
}
<?endif;?>
</script>