mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 22:18:05 -06:00
WebUI: Don't update UI if the page is hidden
Currently, there is unnecessary CPU/network usage by the web UI when it's running in the background, this PR prevents it from refreshing in the background. Closes #22565. PR #22567.
This commit is contained in:
@@ -750,6 +750,8 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
let syncMainDataTimeoutID = -1;
|
||||
let syncRequestInProgress = false;
|
||||
const syncMainData = () => {
|
||||
if (document.hidden)
|
||||
return;
|
||||
syncRequestInProgress = true;
|
||||
const url = new URL("api/v2/sync/maindata", window.location);
|
||||
url.search = new URLSearchParams({
|
||||
@@ -1774,6 +1776,21 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener("visibilitychange", (event) => {
|
||||
if (document.hidden)
|
||||
return;
|
||||
|
||||
switch (LocalPreferences.get("selected_window_tab")) {
|
||||
case "log":
|
||||
window.qBittorrent.Log.load();
|
||||
break;
|
||||
case "transfers":
|
||||
syncData(100);
|
||||
updatePropertiesPanel();
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
|
||||
Reference in New Issue
Block a user