Skip to content

Commit

Permalink
Fix using Fuse.js;
Browse files Browse the repository at this point in the history
  • Loading branch information
HarvelsX committed Dec 19, 2023
1 parent f383b5f commit 40d9dbb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pages/auction/PurchaseComponent/PurchaseComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ const PurchaseComponent: React.FC<PurchaseComponentProps> = ({
}

const { slots } = store.getState().slots;
const { search } = new Fuse(slots, {
const fuse = new Fuse(slots, {
includeScore: true,
shouldSort: true,
threshold: 0.8,
ignoreLocation: true,
keys: ['name'],
});
const match = search(message)[0];

return match.score && match.score > 0.4 ? { ...match.item, index: match.refIndex } : null;
const match = fuse.search(message)[0];
return (match && { ...match.item, index: match.refIndex }) ?? null;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit 40d9dbb

Please sign in to comment.