Merge branch 'improve-emoji-search' into 'develop'
Improve emoji search See merge request soapbox-pub/soapbox!2548
This commit is contained in:
commit
0a66a565f6
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue