Skip to content

Commit

Permalink
WebUI: Eliminate unnecessary torrents table updates
Browse files Browse the repository at this point in the history
Only update the torrents table when torrents are added, edited, or removed.

PR #21656.
  • Loading branch information
Piccirello authored Oct 31, 2024
1 parent 72cbc83 commit 8991d99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/webui/www/private/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,14 @@ window.addEventListener("DOMContentLoaded", () => {
let update_categories = false;
let updateTags = false;
let updateTrackers = false;
let updateTorrents = false;
const full_update = (response["full_update"] === true);
if (full_update) {
torrentsTableSelectedRows = torrentsTable.selectedRowsIds();
update_categories = true;
updateTags = true;
updateTrackers = true;
updateTorrents = true;
torrentsTable.clear();
category_list.clear();
tagList.clear();
Expand Down Expand Up @@ -864,6 +866,7 @@ window.addEventListener("DOMContentLoaded", () => {
update_categories = true;
if (addTorrentToTagList(response["torrents"][key]))
updateTags = true;
updateTorrents = true;
}
}
if (response["torrents_removed"]) {
Expand All @@ -874,8 +877,13 @@ window.addEventListener("DOMContentLoaded", () => {
removeTorrentFromTagList(hash);
updateTags = true; // Always to update All tag
});
updateTorrents = true;
}
torrentsTable.updateTable(full_update);

// don't update the table unnecessarily
if (updateTorrents)
torrentsTable.updateTable(full_update);

if (response["server_state"]) {
const tmp = response["server_state"];
for (const k in tmp) {
Expand Down

0 comments on commit 8991d99

Please sign in to comment.