Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash #610

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading