mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
Fetch data less frequently when torrents tab isn't visible
This commit is contained in:
committed by
sledgehammer999
parent
1a8a6dcef7
commit
2f0646e7f0
@@ -38,7 +38,8 @@ var updateTorrentFilesData = function() {};
|
|||||||
var updateMainData = function() {};
|
var updateMainData = function() {};
|
||||||
var alternativeSpeedLimits = false;
|
var alternativeSpeedLimits = false;
|
||||||
var queueing_enabled = true;
|
var queueing_enabled = true;
|
||||||
var syncMainDataTimerPeriod = 1500;
|
var serverSyncMainDataInterval = 1500;
|
||||||
|
var customSyncMainDataInterval = null;
|
||||||
|
|
||||||
var clipboardEvent;
|
var clipboardEvent;
|
||||||
|
|
||||||
@@ -68,6 +69,10 @@ function genHash(string) {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSyncMainDataInterval() {
|
||||||
|
return customSyncMainDataInterval ? customSyncMainDataInterval : serverSyncMainDataInterval;
|
||||||
|
}
|
||||||
|
|
||||||
window.addEvent('load', function() {
|
window.addEvent('load', function() {
|
||||||
|
|
||||||
var saveColumnSizes = function() {
|
var saveColumnSizes = function() {
|
||||||
@@ -421,7 +426,7 @@ window.addEvent('load', function() {
|
|||||||
torrentsTable.reselectRows(torrentsTableSelectedRows);
|
torrentsTable.reselectRows(torrentsTableSelectedRows);
|
||||||
}
|
}
|
||||||
clearTimeout(syncMainDataTimer);
|
clearTimeout(syncMainDataTimer);
|
||||||
syncMainDataTimer = syncMainData.delay(syncMainDataTimerPeriod);
|
syncMainDataTimer = syncMainData.delay(getSyncMainDataInterval());
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
@@ -502,9 +507,7 @@ window.addEvent('load', function() {
|
|||||||
updateAltSpeedIcon(alternativeSpeedLimits);
|
updateAltSpeedIcon(alternativeSpeedLimits);
|
||||||
}
|
}
|
||||||
|
|
||||||
syncMainDataTimerPeriod = serverState.refresh_interval;
|
serverSyncMainDataInterval = Math.max(serverState.refresh_interval, 500);
|
||||||
if (syncMainDataTimerPeriod < 500)
|
|
||||||
syncMainDataTimerPeriod = 500;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateAltSpeedIcon = function(enabled) {
|
var updateAltSpeedIcon = function(enabled) {
|
||||||
@@ -601,6 +604,11 @@ window.addEvent('load', function() {
|
|||||||
$("filtersColumn").removeClass("invisible");
|
$("filtersColumn").removeClass("invisible");
|
||||||
$("filtersColumn_handle").removeClass("invisible");
|
$("filtersColumn_handle").removeClass("invisible");
|
||||||
$("mainColumn").removeClass("invisible");
|
$("mainColumn").removeClass("invisible");
|
||||||
|
|
||||||
|
customSyncMainDataInterval = null;
|
||||||
|
clearTimeout(syncMainDataTimer);
|
||||||
|
syncMainDataTimer = syncMainData.delay(100);
|
||||||
|
|
||||||
hideSearchTab();
|
hideSearchTab();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -613,6 +621,7 @@ window.addEvent('load', function() {
|
|||||||
|
|
||||||
var showSearchTab = function() {
|
var showSearchTab = function() {
|
||||||
$("searchTabColumn").removeClass("invisible");
|
$("searchTabColumn").removeClass("invisible");
|
||||||
|
customSyncMainDataInterval = 30000;
|
||||||
hideTransfersTab();
|
hideTransfersTab();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -828,7 +837,7 @@ var loadTorrentPeersData = function() {
|
|||||||
syncTorrentPeersLastResponseId = 0;
|
syncTorrentPeersLastResponseId = 0;
|
||||||
torrentPeersTable.clear();
|
torrentPeersTable.clear();
|
||||||
clearTimeout(loadTorrentPeersTimer);
|
clearTimeout(loadTorrentPeersTimer);
|
||||||
loadTorrentPeersTimer = loadTorrentPeersData.delay(syncMainDataTimerPeriod);
|
loadTorrentPeersTimer = loadTorrentPeersData.delay(getSyncMainDataInterval());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var url = new URI('api/v2/sync/torrentPeers');
|
var url = new URI('api/v2/sync/torrentPeers');
|
||||||
@@ -882,7 +891,7 @@ var loadTorrentPeersData = function() {
|
|||||||
torrentPeersTable.clear();
|
torrentPeersTable.clear();
|
||||||
}
|
}
|
||||||
clearTimeout(loadTorrentPeersTimer);
|
clearTimeout(loadTorrentPeersTimer);
|
||||||
loadTorrentPeersTimer = loadTorrentPeersData.delay(syncMainDataTimerPeriod);
|
loadTorrentPeersTimer = loadTorrentPeersData.delay(getSyncMainDataInterval());
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user