Skip to content

Commit

Permalink
Revert "Loadout filters: contains item or mod (#10470)" (#10473)
Browse files Browse the repository at this point in the history
This reverts commit 6f17cd1.
  • Loading branch information
ryan-rushton authored May 29, 2024
1 parent 6f17cd1 commit f18f0d6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 61 deletions.
1 change: 0 additions & 1 deletion config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
"Instructions": "Click or drag files"
},
"LoadoutFilter": {
"Contains": "Shows loadouts which have an item or a mod matching the filter text. Search for items with spaces in their name using quotes.",
"Name": "Shows loadouts whose name matches (exactname:) or partially matches (name:) the filter text. Search for entire phrases using quotes.",
"Notes": "Search for loadouts by their notes field.",
"PartialMatch": "Shows loadouts where their name or notes has a partial match to the filter text. Search for entire phrases using quotes.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports[`buildSearchConfig generates a reasonable filter map: is filters 1`] = `

exports[`buildSearchConfig generates a reasonable filter map: key-value filters 1`] = `
[
"contains",
"exactname",
"keyword",
"name",
Expand Down
65 changes: 7 additions & 58 deletions src/app/search/loadouts/search-filters/freeform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ const freeformFilters: FilterDefinition<
keywords: ['name', 'exactname'],
description: tl('LoadoutFilter.Name'),
format: 'freeform',
suggestionsGenerator: ({ loadouts, selectedLoadoutsStore }) =>
loadouts
?.filter((loadout) => loadout.classType === selectedLoadoutsStore?.classType)
.map((loadout) => `exactname:${quoteFilterString(loadout.name.toLowerCase())}`),
suggestionsGenerator: ({ loadouts }) =>
loadouts?.map((loadout) => `exactname:${quoteFilterString(loadout.name.toLowerCase())}`),
filter: ({ filterValue, language, lhs }) => {
const test = matchText(filterValue, language, /* exact */ lhs === 'exactname');
return (loadout) => test(loadout.name);
Expand Down Expand Up @@ -90,53 +88,6 @@ const freeformFilters: FilterDefinition<
};
},
},
{
keywords: 'contains',
description: tl('LoadoutFilter.Contains'),
format: 'freeform',
suggestionsGenerator: ({ d2Definitions, loadouts, selectedLoadoutsStore }) => {
if (!d2Definitions || !loadouts) {
return [];
}

return loadouts.flatMap((loadout) => {
if (loadout.classType !== selectedLoadoutsStore?.classType) {
return [];
}

const itemSuggestions = loadout.items.map((item) => {
const definition = d2Definitions.InventoryItem.get(item.hash);
return `contains:${quoteFilterString(definition.displayProperties.name.toLowerCase())}`;
});
const modSuggestions =
loadout.parameters?.mods?.map((modHash) => {
const definition = d2Definitions.InventoryItem.get(modHash);
return `contains:${quoteFilterString(definition.displayProperties.name.toLowerCase())}`;
}) || [];

return deduplicate([...itemSuggestions, ...modSuggestions]);
});
},
filter: ({ filterValue, language, d2Definitions, selectedLoadoutsStore }) => {
const test = matchText(filterValue, language, false);
return (loadout) => {
if (!d2Definitions || loadout.classType !== selectedLoadoutsStore.classType) {
return false;
}

return (
loadout.items.some((item) => {
const itemDefinition = d2Definitions.InventoryItem.get(item.hash);
return itemDefinition && test(itemDefinition.displayProperties.name);
}) ||
loadout.parameters?.mods?.some((mod) => {
const modDefinition = d2Definitions.InventoryItem.get(mod);
return modDefinition && test(modDefinition.displayProperties.name);
})
);
};
},
},
{
keywords: 'notes',
description: tl('LoadoutFilter.Notes'),
Expand All @@ -151,16 +102,14 @@ const freeformFilters: FilterDefinition<
keywords: 'keyword',
description: tl('LoadoutFilter.PartialMatch'),
format: 'freeform',
suggestionsGenerator: ({ loadouts, selectedLoadoutsStore }) =>
suggestionsGenerator: ({ loadouts }) =>
loadouts
? Array.from(
new Set([
...loadouts
.filter((loadout) => loadout.classType === selectedLoadoutsStore?.classType)
.flatMap((loadout) => [
...getHashtagsFromNote(loadout.name),
...getHashtagsFromNote(loadout.notes),
]),
...loadouts.flatMap((loadout) => [
...getHashtagsFromNote(loadout.name),
...getHashtagsFromNote(loadout.notes),
]),
]),
)
: [],
Expand Down
1 change: 0 additions & 1 deletion src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@
"UnlockItem": "Unpin Item"
},
"LoadoutFilter": {
"Contains": "Shows loadouts which have an item or a mod matching the filter text. Search for items with spaces in their name using quotes.",
"FashionOnly": "Shows loadouts that contain only fashion (shaders or ornaments).",
"ModsOnly": "Shows loadouts that only contain armor mods.",
"Name": "Shows loadouts whose name matches (exactname:) or partially matches (name:) the filter text. Search for entire phrases using quotes.",
Expand Down

0 comments on commit f18f0d6

Please sign in to comment.