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', () => {
|
it('orders search results correctly', () => {
|
||||||
const expected = [
|
const expected = [
|
||||||
{
|
{ id: 'apple', unified: '1f34e', native: '🍎' },
|
||||||
id: 'pineapple',
|
{ id: 'pineapple', unified: '1f34d', native: '🍍' },
|
||||||
unified: '1f34d',
|
{ id: 'green_apple', unified: '1f34f', native: '🍏' },
|
||||||
native: '🍍',
|
{ id: 'iphone', unified: '1f4f1', native: '📱' },
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'apple',
|
|
||||||
unified: '1f34e',
|
|
||||||
native: '🍎',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'green_apple',
|
|
||||||
unified: '1f34f',
|
|
||||||
native: '🍏',
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
expect(search('apple').map(trimEmojis)).toEqual(expected);
|
expect(search('apple').map(trimEmojis)).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,9 @@ const index = new Index({
|
||||||
context: true,
|
context: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const [key, emoji] of Object.entries(data.emojis)) {
|
const sortedEmojis = Object.entries(data.emojis).sort((a, b) => a[0].localeCompare(b[0]));
|
||||||
index.add('n' + key, emoji.name);
|
for (const [key, emoji] of sortedEmojis) {
|
||||||
|
index.add('n' + key, `${emoji.id} ${emoji.name} ${emoji.keywords.join(' ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface searchOptions {
|
export interface searchOptions {
|
||||||
|
|
Loading…
Reference in New Issue