Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Aug 11, 2023
1 parent f58929c commit f7acec1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/components/barters-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ function BartersTable({ selectedTrader, nameFilter, itemFilter, showAll, useBart
}
if (!rewardItem.item.containsItems) continue;
for (const contained of rewardItem.item.containsItems) {
if (!contained) {
continue;
}
if (contained.item.id === itemFilter) {
return true;
}
Expand Down
32 changes: 16 additions & 16 deletions src/features/barters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,26 @@ export const selectAllBarters = createSelector([selectBarters, selectQuests, sel
}
return {
...barter,
requiredItems: barter.requiredItems.map(req => {
requiredItems: barter.requiredItems.reduce((requirements, req) => {
let matchedItem = items.find(it => it.id === req.item.id);
if (!matchedItem) {
return false;
if (matchedItem) {
requirements.push({
...req,
item: matchedItem,
});
}
return {
...req,
item: matchedItem,
};
}).filter(Boolean),
rewardItems: barter.rewardItems.map(req => {
return requirements;
}, []),
rewardItems: barter.rewardItems.reduce((requirements, req) => {
const matchedItem = items.find(it => it.id === req.item.id);
if (!matchedItem) {
return false;
if (matchedItem) {
requirements.push({
...req,
item: matchedItem,
});
}
return {
...req,
item: matchedItem,
};
}).filter(Boolean),
return requirements;
}, []),
taskUnlock: taskUnlock,
};
}).filter(barter => barter.rewardItems.length > 0 && barter.requiredItems.length > 0);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ function Item() {
const containsItems = currentItemData?.containsItems?.length > 0;

const hasBarters = barters.some(barter => {
let requiredItems = barter.requiredItems.some(contained => contained.item.id === currentItemData.id);
let rewardItems = barter.rewardItems.some(contained => contained.item.id === currentItemData.id ||
contained.item.containsItems.some(ci => ci.item.id === currentItemData.id));
let requiredItems = barter.requiredItems.some(contained => contained?.item.id === currentItemData.id);
let rewardItems = barter.rewardItems.some(contained => contained?.item.id === currentItemData.id ||
contained?.item.containsItems.some(ci => ci?.item.id === currentItemData.id));

return requiredItems || rewardItems;
});
Expand Down

0 comments on commit f7acec1

Please sign in to comment.