Don’t call useless `emojisToShowFilter` when undefined
parent
046d489d7f
commit
4a9497df0e
|
@ -59,23 +59,27 @@ export default class Picker extends React.Component {
|
|||
let isExcluded = props.exclude == undefined ? false : props.exclude.indexOf(category.name.toLowerCase()) > -1
|
||||
if (!isIncluded || isExcluded) { continue }
|
||||
|
||||
let newEmojis = []
|
||||
if (props.emojisToShowFilter) {
|
||||
let newEmojis = []
|
||||
|
||||
for (let emoji of category.emojis) {
|
||||
let unified = data.emojis[emoji].unified
|
||||
for (let emoji of category.emojis) {
|
||||
let unified = data.emojis[emoji].unified
|
||||
|
||||
if (props.emojisToShowFilter(unified)) {
|
||||
newEmojis.push(emoji)
|
||||
}
|
||||
}
|
||||
|
||||
if (newEmojis.length) {
|
||||
let newCategory = {
|
||||
emojis: newEmojis,
|
||||
name: category.name,
|
||||
if (props.emojisToShowFilter(unified)) {
|
||||
newEmojis.push(emoji)
|
||||
}
|
||||
}
|
||||
|
||||
this.categories.push(newCategory)
|
||||
if (newEmojis.length) {
|
||||
let newCategory = {
|
||||
emojis: newEmojis,
|
||||
name: category.name,
|
||||
}
|
||||
|
||||
this.categories.push(newCategory)
|
||||
}
|
||||
} else {
|
||||
this.categories.push(category)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,6 +399,6 @@ Picker.defaultProps = {
|
|||
native: Emoji.defaultProps.native,
|
||||
sheetSize: Emoji.defaultProps.sheetSize,
|
||||
backgroundImageFn: Emoji.defaultProps.backgroundImageFn,
|
||||
emojisToShowFilter: (codePoint) => true,
|
||||
emojisToShowFilter: null,
|
||||
autoFocus: false,
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ Search.propTypes = {
|
|||
Search.defaultProps = {
|
||||
onSearch: (() => {}),
|
||||
maxResults: 75,
|
||||
emojisToShowFilter: () => true,
|
||||
emojisToShowFilter: null,
|
||||
autoFocus: false,
|
||||
}
|
||||
|
|
|
@ -92,16 +92,17 @@ function search(value, emojisToShowFilter = () => true, maxResults = 75) {
|
|||
}
|
||||
}
|
||||
|
||||
let filteredResults = null
|
||||
|
||||
if (results) {
|
||||
filteredResults = results.filter((result) => emojisToShowFilter(data.emojis[result.id].unified))
|
||||
if (filteredResults && filteredResults.length) {
|
||||
filteredResults = filteredResults.slice(0, maxResults)
|
||||
if (emojisToShowFilter) {
|
||||
results = results.filter((result) => emojisToShowFilter(data.emojis[result.id].unified))
|
||||
}
|
||||
|
||||
if (results && results.length) {
|
||||
results = results.slice(0, maxResults)
|
||||
}
|
||||
}
|
||||
|
||||
return filteredResults
|
||||
return results
|
||||
}
|
||||
|
||||
export default { search, emojis: emojisList, emoticons: emoticonsList }
|
||||
|
|
Loading…
Reference in New Issue