Clearing custom emojis from index and pool when necessary
parent
1ea0048d3e
commit
bf8ffe5413
|
@ -5,6 +5,7 @@ var originalPool = {}
|
||||||
var index = {}
|
var index = {}
|
||||||
var emojisList = {}
|
var emojisList = {}
|
||||||
var emoticonsList = {}
|
var emoticonsList = {}
|
||||||
|
var customEmojisList = []
|
||||||
|
|
||||||
for (let emoji in data.emojis) {
|
for (let emoji in data.emojis) {
|
||||||
let emojiData = data.emojis[emoji],
|
let emojiData = data.emojis[emoji],
|
||||||
|
@ -25,7 +26,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]
|
||||||
|
|
||||||
|
@ -34,13 +46,16 @@ function addCustomToPool(custom, pool) {
|
||||||
emojisList[emojiId] = getSanitizedData(emoji)
|
emojisList[emojiId] = getSanitizedData(emoji)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
customEmojisList = custom
|
||||||
|
index = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(
|
function search(
|
||||||
value,
|
value,
|
||||||
{ emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}
|
{ emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}
|
||||||
) {
|
) {
|
||||||
addCustomToPool(custom, originalPool)
|
if (customEmojisList != custom) addCustomToPool(custom, originalPool)
|
||||||
|
|
||||||
maxResults || (maxResults = 75)
|
maxResults || (maxResults = 75)
|
||||||
include || (include = [])
|
include || (include = [])
|
||||||
|
|
Loading…
Reference in New Issue