Don’t call useless `emojisToShowFilter` when undefined
parent
046d489d7f
commit
4a9497df0e
|
@ -59,6 +59,7 @@ export default class Picker extends React.Component {
|
|||
let isExcluded = props.exclude == undefined ? false : props.exclude.indexOf(category.name.toLowerCase()) > -1
|
||||
if (!isIncluded || isExcluded) { continue }
|
||||
|
||||
if (props.emojisToShowFilter) {
|
||||
let newEmojis = []
|
||||
|
||||
for (let emoji of category.emojis) {
|
||||
|
@ -77,6 +78,9 @@ export default class Picker extends React.Component {
|
|||
|
||||
this.categories.push(newCategory)
|
||||
}
|
||||
} else {
|
||||
this.categories.push(category)
|
||||
}
|
||||
}
|
||||
|
||||
let includeRecent = props.include == undefined ? true : props.include.indexOf('recent') > -1
|
||||
|
@ -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