From e10a779150e650d8548ab0ce8c8a790de70c4a59 Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Fri, 26 May 2017 11:19:07 +0200 Subject: [PATCH] Add support for custom emojis to EmojiIndex#search --- src/utils/emoji-index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/utils/emoji-index.js b/src/utils/emoji-index.js index 7f48063..feff1a2 100644 --- a/src/utils/emoji-index.js +++ b/src/utils/emoji-index.js @@ -1,7 +1,7 @@ const extend = require('util')._extend import data from '../../data' -import { getSanitizedData, intersect } from '.' +import { getData, getSanitizedData, intersect } from '.' var index = {} var emojisList = {} @@ -21,9 +21,21 @@ for (let emoji in data.emojis) { emojisList[id] = getSanitizedData(id) } -function search(value, { emojisToShowFilter, maxResults, include, exclude } = {}) { +function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) { maxResults || (maxResults = 75) + if (custom.length) { + for (const emoji of custom) { + data.emojis[emoji.id] = getData(emoji) + emojisList[emoji.id] = getSanitizedData(emoji) + } + + data.categories.push({ + name: 'Custom', + emojis: custom.map(emoji => emoji.id) + }) + } + var results = null, pool = data.emojis