Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
perunt committed Mar 9, 2023
1 parent 2f1befd commit ca9f306
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/components/EmojiSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ const measureHeightOfEmojiRows = (numRows, isEmojiPickerLarge) => {
};

/**
* Create unique keys for each emoji item
* @param {Object} item
* @param {Number} index
* @returns {String}
*/
* Create unique keys for each emoji item
* @param {Object} item
* @param {Number} index
* @returns {String}
*/
const keyExtractor = (item, index) => `${item.name}+${index}}`;

const EmojiSuggestions = (props) => {
Expand All @@ -93,7 +93,7 @@ const EmojiSuggestions = (props) => {
onPress={() => props.onSelect(index)}
>
<View style={styles.emojiSuggestionContainer}>
<Text style={styles.emojiSuggestionsEmoji}>{EmojiUtils.emojiCode(item, props.preferredSkinToneIndex)}</Text>
<Text style={styles.emojiSuggestionsEmoji}>{EmojiUtils.getEmojiCodeWithSkinColor(item, props.preferredSkinToneIndex)}</Text>
<Text style={styles.emojiSuggestionsText}>
:
{_.map(styledTextArray, ({text, isColored}, i) => (
Expand Down
4 changes: 2 additions & 2 deletions src/libs/EmojiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function suggestEmojis(text, limit = 5) {
* @param {Number} preferredSkinToneIndex
* @returns {String}
*/
const emojiCode = (item, preferredSkinToneIndex) => {
const getEmojiCodeWithSkinColor = (item, preferredSkinToneIndex) => {
const {code, types} = item;
if (types && types[preferredSkinToneIndex]) {
return types[preferredSkinToneIndex];
Expand All @@ -271,5 +271,5 @@ export {
replaceEmojis,
suggestEmojis,
trimEmojiUnicode,
emojiCode,
getEmojiCodeWithSkinColor,
};
1 change: 0 additions & 1 deletion src/libs/GetStyledTextArray.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Render a suggestion menu item component.
* @param {String} name
Expand Down
10 changes: 5 additions & 5 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ const getMaxArrowIndex = (numRows, isEmojiPickerLarge) => {
class ReportActionCompose extends React.Component {
constructor(props) {
super(props);
this.calculateEmojiSuggestionDebounce = _.debounce(this.calculateEmojiSuggestion, 10, false);

this.calculateEmojiSuggestion = _.debounce(this.calculateEmojiSuggestion, 10, false);
this.updateComment = this.updateComment.bind(this);
this.debouncedSaveReportComment = _.debounce(this.debouncedSaveReportComment.bind(this), 1000, false);
this.debouncedBroadcastUserIsTyping = _.debounce(this.debouncedBroadcastUserIsTyping.bind(this), 100, true);
Expand Down Expand Up @@ -249,7 +248,7 @@ class ReportActionCompose extends React.Component {

onSelectionChange(e) {
this.setState({selection: e.nativeEvent.selection});
this.calculateEmojiSuggestionDebounce();
this.calculateEmojiSuggestion();
}

/**
Expand Down Expand Up @@ -826,9 +825,10 @@ class ReportActionCompose extends React.Component {
value={this.state.value}
onLayout={(e) => {
const composerHeight = e.nativeEvent.layout.height;
if (this.state.composerHeight !== composerHeight) {
this.setState({composerHeight});
if (this.state.composerHeight === composerHeight) {
return;
}
this.setState({composerHeight});
}}
onScroll={this.setShouldShowSuggestionMenuToFalse}
/>
Expand Down

0 comments on commit ca9f306

Please sign in to comment.