Fix include / exclude [Fix #149]

Since fdf3c2d
release
Etienne Lemay 2017-12-15 15:04:51 -05:00
parent 1a4a44e449
commit 453f723d5e
2 changed files with 9 additions and 12 deletions

View File

@ -62,10 +62,7 @@ export default class Picker extends React.PureComponent {
if (props.include != undefined) { if (props.include != undefined) {
allCategories.sort((a, b) => { allCategories.sort((a, b) => {
let aName = a.name.toLowerCase() if (props.include.indexOf(a.id) > props.include.indexOf(b.id)) {
let bName = b.name.toLowerCase()
if (props.include.indexOf(aName) > props.include.indexOf(bName)) {
return 1 return 1
} }
@ -81,11 +78,11 @@ export default class Picker extends React.PureComponent {
const category = allCategories[categoryIndex] const category = allCategories[categoryIndex]
let isIncluded = let isIncluded =
props.include && props.include.length props.include && props.include.length
? props.include.indexOf(category.name.toLowerCase()) > -1 ? props.include.indexOf(category.id) > -1
: true : true
let isExcluded = let isExcluded =
props.exclude && props.exclude.length props.exclude && props.exclude.length
? props.exclude.indexOf(category.name.toLowerCase()) > -1 ? props.exclude.indexOf(category.id) > -1
: false : false
if (!isIncluded || isExcluded) { if (!isIncluded || isExcluded) {
continue continue
@ -117,11 +114,11 @@ export default class Picker extends React.PureComponent {
let includeRecent = let includeRecent =
props.include && props.include.length props.include && props.include.length
? props.include.indexOf('recent') > -1 ? props.include.indexOf(RECENT_CATEGORY.id) > -1
: true : true
let excludeRecent = let excludeRecent =
props.exclude && props.exclude.length props.exclude && props.exclude.length
? props.exclude.indexOf('recent') > -1 ? props.exclude.indexOf(RECENT_CATEGORY.id) > -1
: false : false
if (includeRecent && !excludeRecent) { if (includeRecent && !excludeRecent) {
this.hideRecent = false this.hideRecent = false
@ -466,9 +463,9 @@ export default class Picker extends React.PureComponent {
native={native} native={native}
hasStickyPosition={this.hasStickyPosition} hasStickyPosition={this.hasStickyPosition}
i18n={this.i18n} i18n={this.i18n}
recent={category.name == 'Recent' ? recent : undefined} recent={category.id == RECENT_CATEGORY.id ? recent : undefined}
custom={ custom={
category.name == 'Recent' ? CUSTOM_CATEGORY.emojis : undefined category.id == RECENT_CATEGORY.id ? CUSTOM_CATEGORY.emojis : undefined
} }
emojiProps={{ emojiProps={{
native: native, native: native,

View File

@ -67,11 +67,11 @@ function search(
data.categories.forEach(category => { data.categories.forEach(category => {
let isIncluded = let isIncluded =
include && include.length include && include.length
? include.indexOf(category.name.toLowerCase()) > -1 ? include.indexOf(category.id) > -1
: true : true
let isExcluded = let isExcluded =
exclude && exclude.length exclude && exclude.length
? exclude.indexOf(category.name.toLowerCase()) > -1 ? exclude.indexOf(category.id) > -1
: false : false
if (!isIncluded || isExcluded) { if (!isIncluded || isExcluded) {
return return