-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Add filterFunctions prop to enable emojis filtering #34
Changes from 3 commits
60feb0c
b3176f6
fcf92d5
4857b89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,11 +282,12 @@ class EmojiInput extends React.PureComponent { | |
} | ||
}; | ||
|
||
emojiRenderer = emoji => { | ||
emojiRenderer = emojis => { | ||
let dataProvider = new DataProvider((e1, e2) => { | ||
return e1.char !== e2.char; | ||
}); | ||
|
||
this.filteredEmojis = _(emojis).pickBy(emoji => _.every(this.props.filterFunctions, fn => fn(emoji))).value(); | ||
this.emoji = []; | ||
let categoryIndexMap = _(category) | ||
.map((v, idx) => ({ ...v, idx })) | ||
|
@@ -298,7 +299,7 @@ class EmojiInput extends React.PureComponent { | |
.map((v, k) => [ | ||
{ char: category[k].key, categoryMarker: true, ...category[k] } | ||
]); | ||
_(emoji) | ||
_(this.filteredEmojis) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do the following
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed 👍 |
||
.values() | ||
.each(e => { | ||
if (_.has(categoryIndexMap, e.category)) { | ||
|
@@ -633,7 +634,8 @@ EmojiInput.defaultProps = { | |
}, | ||
emojiFontSize: 40, | ||
categoryFontSize: 20, | ||
resetSearch: false | ||
resetSearch: false, | ||
filterFunctions: [] | ||
}; | ||
|
||
EmojiInput.propTypes = { | ||
|
@@ -657,7 +659,8 @@ EmojiInput.propTypes = { | |
enableFrequentlyUsedEmoji: PropTypes.bool, | ||
numFrequentlyUsedEmoji: PropTypes.number, | ||
defaultFrequentlyUsedEmoji: PropTypes.arrayOf(PropTypes.string), | ||
resetSearch: PropTypes.bool | ||
resetSearch: PropTypes.bool, | ||
filterFunctions: PropTypes.arrayOf(PropTypes.func) | ||
}; | ||
|
||
const styles = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,11 +282,12 @@ class EmojiInput extends React.PureComponent { | |
} | ||
}; | ||
|
||
emojiRenderer = emoji => { | ||
emojiRenderer = emojis => { | ||
let dataProvider = new DataProvider((e1, e2) => { | ||
return e1.char !== e2.char; | ||
}); | ||
|
||
this.filteredEmojis = _(emojis).pickBy(emoji => _.every(this.props.filterFunctions, fn => fn(emoji))).value(); | ||
this.emoji = []; | ||
let categoryIndexMap = _(category) | ||
.map((v, idx) => ({ ...v, idx })) | ||
|
@@ -298,7 +299,7 @@ class EmojiInput extends React.PureComponent { | |
.map((v, k) => [ | ||
{ char: category[k].key, categoryMarker: true, ...category[k] } | ||
]); | ||
_(emoji) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rename it to emojis There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have changed the param of function to |
||
_(this.filteredEmojis) | ||
.values() | ||
.each(e => { | ||
if (_.has(categoryIndexMap, e.category)) { | ||
|
@@ -633,7 +634,8 @@ EmojiInput.defaultProps = { | |
}, | ||
emojiFontSize: 40, | ||
categoryFontSize: 20, | ||
resetSearch: false | ||
resetSearch: false, | ||
filterFunctions: [] | ||
}; | ||
|
||
EmojiInput.propTypes = { | ||
|
@@ -657,7 +659,8 @@ EmojiInput.propTypes = { | |
enableFrequentlyUsedEmoji: PropTypes.bool, | ||
numFrequentlyUsedEmoji: PropTypes.number, | ||
defaultFrequentlyUsedEmoji: PropTypes.arrayOf(PropTypes.string), | ||
resetSearch: PropTypes.bool | ||
resetSearch: PropTypes.bool, | ||
filterFunctions: PropTypes.arrayOf(PropTypes.func) | ||
}; | ||
|
||
const styles = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to assign
filteredEmojis
to this component? The value will only be used inside the function, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filteredEmoji
is not needed anymore so I have removed that.