Skip to content

Commit

Permalink
fix: filter only valid entities
Browse files Browse the repository at this point in the history
  • Loading branch information
renanvalentin committed Mar 12, 2024
1 parent 501e501 commit 850ca49
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ui/app/components/assetsViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ const AssetsViewer = ({ assets }) => {
}
setAssetsArray(null);
await new Promise((res, rej) => setTimeout(() => res(), 10));
const assetsArray = [];
let i = 0;
const filter = (asset) =>
search
? asset.name.toLowerCase().includes(search.toLowerCase()) ||
asset.policy.includes(search) ||
asset.fingerprint.includes(search)
const filter = (asset) => {
const source = [asset.name, asset.policy, asset.fingerprint]
.filter((a) => a !== undefined)
.map((a) => a.toLowerCase());

return search
? source.find((a) => a.includes(search.toLowerCase()))
: true;
};
const filteredAssets = assets.filter(filter);
setTotal(filteredAssets.length);
setAssetsArray(filteredAssets);
Expand Down

0 comments on commit 850ca49

Please sign in to comment.