Fix search with include/exclude [Fix #89]
parent
b90ca821bc
commit
4d57436bbe
|
@ -6,8 +6,8 @@ import { getData, getSanitizedData, intersect } from '.'
|
||||||
var index = {}
|
var index = {}
|
||||||
var emojisList = {}
|
var emojisList = {}
|
||||||
var emoticonsList = {}
|
var emoticonsList = {}
|
||||||
var previousInclude = null
|
var previousInclude = []
|
||||||
var previousExclude = null
|
var previousExclude = []
|
||||||
|
|
||||||
for (let emoji in data.emojis) {
|
for (let emoji in data.emojis) {
|
||||||
let emojiData = data.emojis[emoji],
|
let emojiData = data.emojis[emoji],
|
||||||
|
@ -25,6 +25,8 @@ for (let emoji in data.emojis) {
|
||||||
|
|
||||||
function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
|
function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
|
||||||
maxResults || (maxResults = 75)
|
maxResults || (maxResults = 75)
|
||||||
|
include || (include = [])
|
||||||
|
exclude || (exclude = [])
|
||||||
|
|
||||||
if (custom.length) {
|
if (custom.length) {
|
||||||
for (const emoji of custom) {
|
for (const emoji of custom) {
|
||||||
|
@ -53,7 +55,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
|
||||||
values = [values[0], values[1]]
|
values = [values[0], values[1]]
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((include && include.length) || (exclude && exclude.length)) {
|
if (include.length || exclude.length) {
|
||||||
pool = {}
|
pool = {}
|
||||||
|
|
||||||
if (previousInclude != include.sort().join(',') || previousExclude != exclude.sort().join(',')) {
|
if (previousInclude != include.sort().join(',') || previousExclude != exclude.sort().join(',')) {
|
||||||
|
@ -71,7 +73,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
|
||||||
pool[emojiId] = data.emojis[emojiId]
|
pool[emojiId] = data.emojis[emojiId]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (previousInclude || previousExclude) {
|
} else if (previousInclude.length || previousExclude.length) {
|
||||||
index = {}
|
index = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue