Skip to content

Commit

Permalink
Merge pull request #10381 from FlaminSarge/comparezerostat
Browse files Browse the repository at this point in the history
Disallow vendorItems without vendorHash from showing up in compareCategoryItemsSelector
  • Loading branch information
bhollis authored May 24, 2024
2 parents 87791be + 0d84770 commit b68b5b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"IsVendorItem": "This item is not owned. This is in a vendor's inventory and may be for sale.",
"SoldBy": "Sold by: {{vendorName}}",
"Error": {
"Unmatched": "This item doesn't match the type of items being compared."
"Unmatched": "This item doesn't match the type of items being compared.",
"Invalid": "There are no valid items for comparison."
}
},
"Cooldown": {
Expand Down
6 changes: 6 additions & 0 deletions src/app/compare/Compare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'app/inventory/store/override-sockets';
import { recoilValue } from 'app/item-popup/RecoilStat';
import { useD2Definitions } from 'app/manifest/selectors';
import { showNotification } from 'app/notifications/notifications';
import { statLabels } from 'app/organizer/Columns';
import { weaponMasterworkY2SocketTypeHash } from 'app/search/d2-known-values';
import Checkbox from 'app/settings/Checkbox';
Expand Down Expand Up @@ -119,6 +120,11 @@ export default function Compare({ session }: { session: CompareSession }) {
const hasItems = compareItems.length > 0;
useEffect(() => {
if (!hasItems) {
showNotification({
type: 'warning',
title: t('Compare.Error.Invalid'),
body: session.query,
});
cancel();
}
}, [cancel, hasItems]);
Expand Down
6 changes: 4 additions & 2 deletions src/app/compare/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export const compareCategoryItemsSelector = createSelector(
if (!itemCategoryHashes) {
return emptyArray<DimItem>();
}
return [...allItems, ...vendorItems].filter((i) =>
itemCategoryHashes.every((h) => i.itemCategoryHashes.includes(h)),
return [...allItems, ...vendorItems].filter(
(i) =>
(!i.vendor || i.vendor.vendorHash) &&
itemCategoryHashes.every((h) => i.itemCategoryHashes.includes(h)),
);
},
);
Expand Down

0 comments on commit b68b5b8

Please sign in to comment.