@ -8,6 +8,7 @@ let originalPool = {};
let index = { } ;
let index = { } ;
let emojisList = { } ;
let emojisList = { } ;
let emoticonsList = { } ;
let emoticonsList = { } ;
let customEmojisList = [ ] ;
for ( let emoji in data . emojis ) {
for ( let emoji in data . emojis ) {
let emojiData = data . emojis [ emoji ] ;
let emojiData = data . emojis [ emoji ] ;
@ -28,7 +29,18 @@ for (let emoji in data.emojis) {
originalPool [ id ] = emojiData ;
originalPool [ id ] = emojiData ;
}
}
function clearCustomEmojis ( pool ) {
customEmojisList . forEach ( ( emoji ) => {
let emojiId = emoji . id || emoji . short_names [ 0 ] ;
delete pool [ emojiId ] ;
delete emojisList [ emojiId ] ;
} ) ;
}
function addCustomToPool ( custom , pool ) {
function addCustomToPool ( custom , pool ) {
if ( customEmojisList . length ) clearCustomEmojis ( pool ) ;
custom . forEach ( ( emoji ) => {
custom . forEach ( ( emoji ) => {
let emojiId = emoji . id || emoji . short_names [ 0 ] ;
let emojiId = emoji . id || emoji . short_names [ 0 ] ;
@ -37,10 +49,14 @@ function addCustomToPool(custom, pool) {
emojisList [ emojiId ] = getSanitizedData ( emoji ) ;
emojisList [ emojiId ] = getSanitizedData ( emoji ) ;
}
}
} ) ;
} ) ;
customEmojisList = custom ;
index = { } ;
}
}
function search ( value , { emojisToShowFilter , maxResults , include , exclude , custom = [ ] } = { } ) {
function search ( value , { emojisToShowFilter , maxResults , include , exclude , custom = [ ] } = { } ) {
addCustomToPool ( custom , originalPool ) ;
if ( customEmojisList !== custom )
addCustomToPool ( custom , originalPool ) ;
maxResults = maxResults || 75 ;
maxResults = maxResults || 75 ;
include = include || [ ] ;
include = include || [ ] ;
@ -143,7 +159,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
if ( results ) {
if ( results ) {
if ( emojisToShowFilter ) {
if ( emojisToShowFilter ) {
results = results . filter ( ( result ) => emojisToShowFilter ( data . emojis [ result . id ] . unified )) ;
results = results . filter ( ( result ) => emojisToShowFilter ( data . emojis [ result . id ] ) ) ;
}
}
if ( results && results . length > maxResults ) {
if ( results && results . length > maxResults ) {