only poll perfstats if the widget id actually visible (the widget is mostly hidden when viewing content in HQ)

This commit is contained in:
Mario
2026-03-02 07:34:43 +00:00
parent add26a5b5f
commit 3256aa8be9

View File

@@ -21,6 +21,10 @@
last_q: 0,
updateStatus: function () {
if (!this.isVisible()) {
return;
}
fetch('/perfstats', {
headers: {
"Accept": "application/json",
@@ -30,7 +34,7 @@
.then((response) => response.json())
.then((json) => {
for (const item in json) {
element = document.getElementById(`perfstat-${item}-value`);
const element = document.getElementById(`perfstat-${item}-value`);
if (element) {
if (item === "loadavg") {
element.innerText = json['loadavg']
@@ -57,6 +61,17 @@
start: function() {
this.updateStatus();
setInterval(() => this.updateStatus(), 5000);
},
isVisible: function () {
const element = document.getElementById('channel-activities');
if (!element) {
return false;
}
const style = window.getComputedStyle(element);
return style.display !== 'none';
}
}