WebUI: Fix error when category doesn't exist

This prevents hitting a TypeError when the category stored in localstorage does not exist. The behavior for a nonexistent category now mirrors that of a nonexistent tag or filter - no option is selected and no torrents are shown.

Closes #20623.
PR #20638.
This commit is contained in:
Thomas Piccirello 2024-04-01 05:15:30 -07:00 committed by GitHub
parent 1d221c22e4
commit 8e6515be2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -1400,10 +1400,13 @@ window.qBittorrent.DynamicTable = (function() {
return false;
}
else {
const selectedCategoryName = category_list.get(categoryHash).name + "/";
const torrentCategoryName = row['full_data'].category + "/";
if (!torrentCategoryName.startsWith(selectedCategoryName))
return false;
const selectedCategory = category_list.get(categoryHash);
if (selectedCategory !== undefined) {
const selectedCategoryName = selectedCategory.name + "/";
const torrentCategoryName = row['full_data'].category + "/";
if (!torrentCategoryName.startsWith(selectedCategoryName))
return false;
}
}
break;
}