mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
WebUI: Keep client session from expiring when the page is hidden
In #22567, I made it so the web UI wouldn't refresh the main data while the page is hidden. This causes the session to time out (after 1 hour by default). This PR changes that to instead refresh every Preferences/WebUI/SessionTimeout / 2 instead of not at all, which should keep the session alive. PR #22804.
This commit is contained in:
parent
c59ac3b970
commit
617b1da842
1 changed files with 6 additions and 3 deletions
|
@ -73,6 +73,9 @@ window.qBittorrent.Client ??= (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSyncMainDataInterval = () => {
|
const getSyncMainDataInterval = () => {
|
||||||
|
// Sync at half of the session timeout (in ms), to prevent timing out
|
||||||
|
if (document.hidden)
|
||||||
|
return (window.qBittorrent.Cache.preferences.get().web_ui_session_timeout * 1000) / 2;
|
||||||
return customSyncMainDataInterval ? customSyncMainDataInterval : serverSyncMainDataInterval;
|
return customSyncMainDataInterval ? customSyncMainDataInterval : serverSyncMainDataInterval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -779,8 +782,6 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||||
let syncMainDataTimeoutID = -1;
|
let syncMainDataTimeoutID = -1;
|
||||||
let syncRequestInProgress = false;
|
let syncRequestInProgress = false;
|
||||||
const syncMainData = () => {
|
const syncMainData = () => {
|
||||||
if (document.hidden)
|
|
||||||
return;
|
|
||||||
syncRequestInProgress = true;
|
syncRequestInProgress = true;
|
||||||
const url = new URL("api/v2/sync/maindata", window.location);
|
const url = new URL("api/v2/sync/maindata", window.location);
|
||||||
url.search = new URLSearchParams({
|
url.search = new URLSearchParams({
|
||||||
|
@ -966,7 +967,9 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||||
if (errorDiv)
|
if (errorDiv)
|
||||||
errorDiv.textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
|
errorDiv.textContent = "QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]";
|
||||||
syncRequestInProgress = false;
|
syncRequestInProgress = false;
|
||||||
syncData(2000);
|
syncData(document.hidden
|
||||||
|
? (window.qBittorrent.Cache.preferences.get().web_ui_session_timeout * 1000) / 2
|
||||||
|
: 2000);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue