Merge branch 'improve-emoji-search' into 'develop'

Improve emoji search

See merge request soapbox-pub/soapbox!2548
environments/review-develop-3zknud/deployments/3465
Chewbacca 2023-06-05 18:37:11 +00:00
commit 0a66a565f6
2 zmienionych plików z 8 dodań i 17 usunięć

Wyświetl plik

@ -19,22 +19,12 @@ describe('emoji_index', () => {
it('orders search results correctly', () => {
const expected = [
{
id: 'pineapple',
unified: '1f34d',
native: '🍍',
},
{
id: 'apple',
unified: '1f34e',
native: '🍎',
},
{
id: 'green_apple',
unified: '1f34f',
native: '🍏',
},
{ id: 'apple', unified: '1f34e', native: '🍎' },
{ id: 'pineapple', unified: '1f34d', native: '🍍' },
{ id: 'green_apple', unified: '1f34f', native: '🍏' },
{ id: 'iphone', unified: '1f4f1', native: '📱' },
];
expect(search('apple').map(trimEmojis)).toEqual(expected);
});

Wyświetl plik

@ -11,8 +11,9 @@ const index = new Index({
context: true,
});
for (const [key, emoji] of Object.entries(data.emojis)) {
index.add('n' + key, emoji.name);
const sortedEmojis = Object.entries(data.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(' ')}`);
}
export interface searchOptions {