WebUI: Use Map instead of Mootools Hash in Torrents table

PR #21308.
This commit is contained in:
skomerko 2024-09-16 11:34:49 +02:00 committed by GitHub
parent e06b7f8f4d
commit 6df1f68ead
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 31 deletions

View file

@ -483,14 +483,10 @@ window.addEventListener("DOMContentLoaded", () => {
}
};
const all = torrentsTable.getRowIds().length;
const all = torrentsTable.rows.size;
let uncategorized = 0;
for (const key in torrentsTable.rows) {
if (!Object.hasOwn(torrentsTable.rows, key))
continue;
const row = torrentsTable.rows[key];
if (row["full_data"].category.length === 0)
for (const { full_data: { category } } of torrentsTable.rows.values()) {
if (category.length === 0)
uncategorized += 1;
}
@ -585,12 +581,13 @@ window.addEventListener("DOMContentLoaded", () => {
return tagFilterItem;
};
const torrentsCount = torrentsTable.getRowIds().length;
const torrentsCount = torrentsTable.rows.size;
let untagged = 0;
for (const key in torrentsTable.rows) {
if (Object.hasOwn(torrentsTable.rows, key) && (torrentsTable.rows[key]["full_data"].tags.length === 0))
for (const { full_data: { tags } } of torrentsTable.rows.values()) {
if (tags.length === 0)
untagged += 1;
}
tagFilterList.appendChild(createLink(TAGS_ALL, "QBT_TR(All)QBT_TR[CONTEXT=TagFilterModel]", torrentsCount));
tagFilterList.appendChild(createLink(TAGS_UNTAGGED, "QBT_TR(Untagged)QBT_TR[CONTEXT=TagFilterModel]", untagged));
@ -637,13 +634,14 @@ window.addEventListener("DOMContentLoaded", () => {
return trackerFilterItem;
};
const torrentsCount = torrentsTable.getRowIds().length;
trackerFilterList.appendChild(createLink(TRACKERS_ALL, "QBT_TR(All (%1))QBT_TR[CONTEXT=TrackerFiltersList]", torrentsCount));
const torrentsCount = torrentsTable.rows.size;
let trackerlessTorrentsCount = 0;
for (const key in torrentsTable.rows) {
if (Object.hasOwn(torrentsTable.rows, key) && (torrentsTable.rows[key]["full_data"].trackers_count === 0))
for (const { full_data: { trackers_count: trackersCount } } of torrentsTable.rows.values()) {
if (trackersCount === 0)
trackerlessTorrentsCount += 1;
}
trackerFilterList.appendChild(createLink(TRACKERS_ALL, "QBT_TR(All (%1))QBT_TR[CONTEXT=TrackerFiltersList]", torrentsCount));
trackerFilterList.appendChild(createLink(TRACKERS_TRACKERLESS, "QBT_TR(Trackerless (%1))QBT_TR[CONTEXT=TrackerFiltersList]", trackerlessTorrentsCount));
// Sort trackers by hostname