From 8e6515be2c8cc2b335002ab8913e9dcdd7873204 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello <8296030+Piccirello@users.noreply.github.com> Date: Mon, 1 Apr 2024 05:15:30 -0700 Subject: [PATCH] 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. --- src/webui/www/private/scripts/dynamicTable.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 923d42a23..c01d72cd7 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -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; }