Emoji: Search on short name first, eliminate short_names, proper sort
This commit is contained in:
parent
c87ffcd2e9
commit
25f64a5140
1 changed files with 2 additions and 3 deletions
|
@ -215,12 +215,11 @@ const fuse = new Fuse(data, {
|
||||||
minMatchCharLength: 1,
|
minMatchCharLength: 1,
|
||||||
tokenize: true,
|
tokenize: true,
|
||||||
tokenSeparator: /[-_\s]+/,
|
tokenSeparator: /[-_\s]+/,
|
||||||
keys: ['name', 'short_name', 'short_names'],
|
keys: ['short_name', 'name'],
|
||||||
});
|
});
|
||||||
|
|
||||||
export function search(query: string, count = 0): Array<EmojiData> {
|
export function search(query: string, count = 0): Array<EmojiData> {
|
||||||
// We reverse it because fuse returns low-score results first!
|
const results = fuse.search(query.substr(0, 32));
|
||||||
const results = fuse.search(query.substr(0, 32)).reverse();
|
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
return take(results, count);
|
return take(results, count);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue