WebUI: Improve accuracy of trackers list

This PR fixes various accounting issues with the trackers list. Removing a torrent would not update the trackers list, nor would removing a tracker from a torrent. And removing a tracker with a shared host but unique url (e.g. example.com/1 and example.com/2) would erroneously remove the tracker's host from the list.

Closes #20053.
Closes #20054.
PR  #20601.
This commit is contained in:
Thomas Piccirello 2024-03-29 00:43:49 -07:00 committed by GitHub
parent eb9e98a4b3
commit 4967f977c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 65 additions and 37 deletions

View file

@ -874,9 +874,16 @@ const initializeWindows = function() {
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default:
hashes = trackerList.get(trackerHashInt).torrents;
default: {
const uniqueTorrents = new Set();
for (const torrents of trackerList.get(trackerHashInt).trackerTorrentMap.values()) {
for (const torrent of torrents) {
uniqueTorrents.add(torrent);
}
}
hashes = [...uniqueTorrents];
break;
}
}
if (hashes.length > 0) {
@ -901,9 +908,16 @@ const initializeWindows = function() {
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default:
hashes = trackerList.get(trackerHashInt).torrents;
default: {
const uniqueTorrents = new Set();
for (const torrents of trackerList.get(trackerHashInt).trackerTorrentMap.values()) {
for (const torrent of torrents) {
uniqueTorrents.add(torrent);
}
}
hashes = [...uniqueTorrents];
break;
}
}
if (hashes.length) {
@ -928,9 +942,16 @@ const initializeWindows = function() {
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes('all', CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default:
hashes = trackerList.get(trackerHashInt).torrents;
default: {
const uniqueTorrents = new Set();
for (const torrents of trackerList.get(trackerHashInt).trackerTorrentMap.values()) {
for (const torrent of torrents) {
uniqueTorrents.add(torrent);
}
}
hashes = [...uniqueTorrents];
break;
}
}
if (hashes.length) {