pl-fe: fix emoji search
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
3e45a3142b
commit
8ae3adbe5a
1 changed files with 8 additions and 6 deletions
|
@ -6,7 +6,14 @@ import type { CustomEmoji } from 'pl-api';
|
||||||
|
|
||||||
let emojis: EmojiData['emojis'] = {};
|
let emojis: EmojiData['emojis'] = {};
|
||||||
|
|
||||||
import('./data').then(data => emojis = data.emojis).catch(() => { });
|
import('./data').then(data => {
|
||||||
|
emojis = data.emojis;
|
||||||
|
|
||||||
|
const sortedEmojis = Object.entries(emojis).sort((a, b) => a[0].localeCompare(b[0]));
|
||||||
|
for (const [key, emoji] of sortedEmojis) {
|
||||||
|
index.add('n' + key, `${emoji.id} ${emoji.name} ${emoji.keywords.join(' ')}`);
|
||||||
|
}
|
||||||
|
}).catch(() => { });
|
||||||
|
|
||||||
const index = new FlexSearch.Index({
|
const index = new FlexSearch.Index({
|
||||||
tokenize: 'full',
|
tokenize: 'full',
|
||||||
|
@ -14,11 +21,6 @@ const index = new FlexSearch.Index({
|
||||||
context: true,
|
context: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const sortedEmojis = Object.entries(emojis).sort((a, b) => a[0].localeCompare(b[0]));
|
|
||||||
for (const [key, emoji] of sortedEmojis) {
|
|
||||||
index.add('n' + key, `${emoji.id} ${emoji.name} ${emoji.keywords.join(' ')}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface searchOptions {
|
interface searchOptions {
|
||||||
maxResults?: number;
|
maxResults?: number;
|
||||||
custom?: any;
|
custom?: any;
|
||||||
|
|
Loading…
Reference in a new issue