Improve mod search
This commit is contained in:
parent
59d4e80248
commit
4f5fa4917d
@ -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;
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user