mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
only poll perfstats if the widget id actually visible (the widget is mostly hidden when viewing content in HQ)
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user