Skip to content

Commit

Permalink
Fix search with include/exclude [Fix #89]
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLem committed Jun 27, 2017
1 parent b90ca82 commit 4d57436
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/emoji-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { getData, getSanitizedData, intersect } from '.'
var index = {}
var emojisList = {}
var emoticonsList = {}
var previousInclude = null
var previousExclude = null
var previousInclude = []
var previousExclude = []

for (let emoji in data.emojis) {
let emojiData = data.emojis[emoji],
Expand All @@ -25,6 +25,8 @@ for (let emoji in data.emojis) {

function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
maxResults || (maxResults = 75)
include || (include = [])
exclude || (exclude = [])

if (custom.length) {
for (const emoji of custom) {
Expand Down Expand Up @@ -53,7 +55,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
values = [values[0], values[1]]
}

if ((include && include.length) || (exclude && exclude.length)) {
if (include.length || exclude.length) {
pool = {}

if (previousInclude != include.sort().join(',') || previousExclude != exclude.sort().join(',')) {
Expand All @@ -71,7 +73,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
pool[emojiId] = data.emojis[emojiId]
}
}
} else if (previousInclude || previousExclude) {
} else if (previousInclude.length || previousExclude.length) {
index = {}
}

Expand Down

0 comments on commit 4d57436

Please sign in to comment.