Reset search index when changing include/exclude
parent
b00572dfaf
commit
81ccfbca03
|
@ -6,6 +6,8 @@ import { getSanitizedData, intersect } from '.'
|
||||||
var index = {}
|
var index = {}
|
||||||
var emojisList = {}
|
var emojisList = {}
|
||||||
var emoticonsList = {}
|
var emoticonsList = {}
|
||||||
|
var previousInclude = null
|
||||||
|
var previousExclude = null
|
||||||
|
|
||||||
for (let emoji in data.emojis) {
|
for (let emoji in data.emojis) {
|
||||||
let emojiData = data.emojis[emoji],
|
let emojiData = data.emojis[emoji],
|
||||||
|
@ -42,6 +44,12 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude } = {}
|
||||||
if ((include && include.length) || (exclude && exclude.length)) {
|
if ((include && include.length) || (exclude && exclude.length)) {
|
||||||
pool = {}
|
pool = {}
|
||||||
|
|
||||||
|
if (previousInclude != include.sort().join(',') || previousExclude != exclude.sort().join(',')) {
|
||||||
|
previousInclude = include.sort().join(',')
|
||||||
|
previousExclude = exclude.sort().join(',')
|
||||||
|
index = {}
|
||||||
|
}
|
||||||
|
|
||||||
for (let category of data.categories) {
|
for (let category of data.categories) {
|
||||||
let isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true
|
let isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true
|
||||||
let isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false
|
let isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false
|
||||||
|
@ -51,6 +59,8 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude } = {}
|
||||||
pool[emojiId] = data.emojis[emojiId]
|
pool[emojiId] = data.emojis[emojiId]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (previousInclude || previousExclude) {
|
||||||
|
index = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
allResults = values.map((value) => {
|
allResults = values.map((value) => {
|
||||||
|
|
Loading…
Reference in New Issue