Merge branch 'main' of github.com:thallada/modmapper-web into main

This commit is contained in:
Tyler Hallada 2022-02-08 00:21:39 -05:00
commit df27a85aa1

View File

@ -71,6 +71,7 @@ const SearchBar: React.FC<Props> = ({ clearSelectedCell, counts, map }) => {
searchOptions: { searchOptions: {
fields: ["name"], fields: ["name"],
fuzzy: 0.2, fuzzy: 0.2,
prefix: true,
}, },
}); });
modSearch.current.addAll(data as unknown as Mod[]); modSearch.current.addAll(data as unknown as Mod[]);
@ -101,7 +102,15 @@ const SearchBar: React.FC<Props> = ({ clearSelectedCell, counts, map }) => {
if (counts) { if (counts) {
const countA = counts[resultA.id]; const countA = counts[resultA.id];
const countB = counts[resultB.id]; const countB = counts[resultB.id];
if (countA && countB) return countB[2] - countA[2]; const scoreA = resultA.score;
const scoreB = resultB.score;
if (countA && countB && scoreA && scoreB) {
if (scoreA === scoreB) {
return countB[2] - countA[2];
} else {
return scoreB - scoreA;
}
}
} }
return 0; return 0;
}) })