WebUI: Eliminate unnecessary Status filter list updates

Only update the Status filter list when torrents are removed, added or their state changed.

PR #21866.
This commit is contained in:
skomerko 2024-11-22 13:59:23 +01:00 committed by GitHub
commit 7300b9f759
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -759,6 +759,7 @@ window.addEventListener("DOMContentLoaded", () => {
torrentsFilterInputTimer = -1; torrentsFilterInputTimer = -1;
let torrentsTableSelectedRows; let torrentsTableSelectedRows;
let updateStatuses = false;
let update_categories = false; let update_categories = false;
let updateTags = false; let updateTags = false;
let updateTrackers = false; let updateTrackers = false;
@ -766,6 +767,7 @@ window.addEventListener("DOMContentLoaded", () => {
const full_update = (response["full_update"] === true); const full_update = (response["full_update"] === true);
if (full_update) { if (full_update) {
torrentsTableSelectedRows = torrentsTable.selectedRowsIds(); torrentsTableSelectedRows = torrentsTable.selectedRowsIds();
updateStatuses = true;
update_categories = true; update_categories = true;
updateTags = true; updateTags = true;
updateTrackers = true; updateTrackers = true;
@ -870,6 +872,7 @@ window.addEventListener("DOMContentLoaded", () => {
const state = response["torrents"][key]["state"]; const state = response["torrents"][key]["state"];
response["torrents"][key]["status"] = state; response["torrents"][key]["status"] = state;
response["torrents"][key]["_statusOrder"] = statusSortOrder[state]; response["torrents"][key]["_statusOrder"] = statusSortOrder[state];
updateStatuses = true;
} }
torrentsTable.updateRowData(response["torrents"][key]); torrentsTable.updateRowData(response["torrents"][key]);
if (addTorrentToCategoryList(response["torrents"][key])) if (addTorrentToCategoryList(response["torrents"][key]))
@ -888,6 +891,7 @@ window.addEventListener("DOMContentLoaded", () => {
updateTags = true; // Always to update All tag updateTags = true; // Always to update All tag
}); });
updateTorrents = true; updateTorrents = true;
updateStatuses = true;
} }
// don't update the table unnecessarily // don't update the table unnecessarily
@ -903,7 +907,10 @@ window.addEventListener("DOMContentLoaded", () => {
} }
processServerState(); processServerState();
} }
updateFiltersList();
if (updateStatuses)
updateFiltersList();
if (update_categories) { if (update_categories) {
updateCategoryList(); updateCategoryList();
window.qBittorrent.TransferList.contextMenu.updateCategoriesSubMenu(category_list); window.qBittorrent.TransferList.contextMenu.updateCategoriesSubMenu(category_list);