Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
fix tags filter for addons
Browse files Browse the repository at this point in the history
  • Loading branch information
Raicuparta committed Jan 21, 2023
1 parent 185df73 commit fd96b06
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/store/mods-state/mod-filter-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ import { modTagsSelectionState } from './mod-tags-state';

import { modList } from './mods-state';

const filterByTags = (mod: Mod, tags: Set<string>) => {
const filterByTags = (tags: Set<string>, mod: Mod, mods: Mod[]) => {
if (tags.size === 0) return true;

for (let i = 0; i < mod.tags.length; i += 1) {
if (tags.has(mod.tags[i])) {
return true;
}
if (
mod.addons.find((addonUniqueName) => {
const addon = mods.find(
(modFromList) => modFromList.uniqueName === addonUniqueName
);

return addon && tags.has(addon.tags[i]);
})
) {
return true;
}
}

return false;
};

Expand Down Expand Up @@ -63,7 +75,8 @@ export const filteredModList = selector({
return mods
.filter((mod) => {
return (
filterByText(filter, mod, mods) && filterByTags(mod, tagsSelection)
filterByText(filter, mod, mods) &&
filterByTags(tagsSelection, mod, mods)
);
})
.sort(
Expand Down

0 comments on commit fd96b06

Please sign in to comment.