Skip to content

Commit

Permalink
Optimize logic get search categories
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Mar 4, 2024
1 parent d897d2e commit bbcaad4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,12 +964,17 @@ function getCategoryListSections(
}

if (searchInputValue) {
const searchCategories = enabledCategories
.filter((category) => category.name.toLowerCase().includes(searchInputValue.toLowerCase()))
.map((category) => ({
const searchCategories: Category[] = [];

enabledCategories.forEach((category) => {
if (!category.name.toLowerCase().includes(searchInputValue.toLowerCase())) {
return;
}
searchCategories.push({
...category,
isSelected: selectedOptions.some((selectedOption) => selectedOption.name === category.name),
}));
});
});

categorySections.push({
// "Search" section
Expand Down

0 comments on commit bbcaad4

Please sign in to comment.