Add support for custom emojis to EmojiIndex#search

release
Jakob Krigovsky 2017-05-26 11:19:07 +02:00
parent 289fc0ffc0
commit e10a779150
1 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,7 @@
const extend = require('util')._extend const extend = require('util')._extend
import data from '../../data' import data from '../../data'
import { getSanitizedData, intersect } from '.' import { getData, getSanitizedData, intersect } from '.'
var index = {} var index = {}
var emojisList = {} var emojisList = {}
@ -21,9 +21,21 @@ for (let emoji in data.emojis) {
emojisList[id] = getSanitizedData(id) emojisList[id] = getSanitizedData(id)
} }
function search(value, { emojisToShowFilter, maxResults, include, exclude } = {}) { function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
maxResults || (maxResults = 75) 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, var results = null,
pool = data.emojis pool = data.emojis