Skip to content

Commit

Permalink
simplify traders with barters
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Feb 16, 2024
1 parent b7d7e02 commit dabe249
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/features/traders/do-fetch-traders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export default async function doFetchTraders(language, prebuild = false) {
insuranceRate
repairCostMultiplier
}
barters {
id
}
}
}`;

Expand Down
6 changes: 2 additions & 4 deletions src/pages/barters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import useStateWithLocalStorage from '../../hooks/useStateWithLocalStorage.jsx';

import useTradersData from '../../features/traders/index.js';
import useBartersData from '../../features/barters/index.js';
import { toggleHideDogtagBarters } from '../../features/settings/settingsSlice.js';

import './index.css';
Expand Down Expand Up @@ -47,7 +46,6 @@ function Barters() {

const dispatch = useDispatch();
const { data: allTraders } = useTradersData();
const { data: barters } = useBartersData();

const { t } = useTranslation();

Expand All @@ -56,8 +54,8 @@ function Barters() {
}, [searchParams]);

const traders = useMemo(() => {
return allTraders.filter(trader => barters.some(b => b.trader.id === trader.id));
}, [allTraders, barters]);
return allTraders.filter(trader => trader.barters?.length);
}, [allTraders]);

return [
<SEO
Expand Down

0 comments on commit dabe249

Please sign in to comment.