Skip to content

Commit

Permalink
Merge pull request #610 from the-hideout/fix-website
Browse files Browse the repository at this point in the history
fix crash
  • Loading branch information
Razzmatazzz authored Aug 11, 2023
2 parents 89aa357 + ce0bd99 commit ca13e5d
Show file tree
Hide file tree
Showing 4 changed files with 25 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
3 changes: 3 additions & 0 deletions src/components/small-item-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ function SmallItemTable(props) {
return {};
const filterItems = {};
containedInFilter.forEach(ci => {
if (!ci) {
return;
}
filterItems[ci.item.id] = ci.count;
});
return filterItems;
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 ca13e5d

Please sign in to comment.