Skip to content

Commit

Permalink
Merge pull request #16902 from Expensify/beaman-fixEmojiReplace
Browse files Browse the repository at this point in the history
Remove incorrect `this` from replaceEmojis function
  • Loading branch information
cristipaval authored Apr 4, 2023
2 parents fbf7ba6 + cfe0a24 commit b302017
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/libs/EmojiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ function addToFrequentlyUsedEmojis(frequentlyUsedEmojis, newEmoji) {
User.updateFrequentlyUsedEmojis(frequentEmojiList);
}

/**
* Given an emoji item object, return an emoji code based on its type.
*
* @param {Object} item
* @param {Number} preferredSkinToneIndex
* @returns {String}
*/
const getEmojiCodeWithSkinColor = (item, preferredSkinToneIndex) => {
const {code, types} = item;
if (types && types[preferredSkinToneIndex]) {
return types[preferredSkinToneIndex];
}

return code;
};

/**
* Replace any emoji name in a text with the emoji icon.
* If we're on mobile, we also add a space after the emoji granted there's no text after it.
Expand All @@ -202,7 +218,7 @@ function replaceEmojis(text, isSmallScreenWidth = false, preferredSkinTone = CON
for (let i = 0; i < emojiData.length; i++) {
const checkEmoji = emojisTrie.search(emojiData[i].slice(1, -1));
if (checkEmoji && checkEmoji.metaData.code) {
let emojiReplacement = this.getEmojiCodeWithSkinColor(checkEmoji.metaData, preferredSkinTone);
let emojiReplacement = getEmojiCodeWithSkinColor(checkEmoji.metaData, preferredSkinTone);

// If this is the last emoji in the message and it's the end of the message so far,
// add a space after it so the user can keep typing easily.
Expand Down Expand Up @@ -248,22 +264,6 @@ function suggestEmojis(text, limit = 5) {
return [];
}

/**
* Given an emoji item object, return an emoji code based on its type.
*
* @param {Object} item
* @param {Number} preferredSkinToneIndex
* @returns {String}
*/
const getEmojiCodeWithSkinColor = (item, preferredSkinToneIndex) => {
const {code, types} = item;
if (types && types[preferredSkinToneIndex]) {
return types[preferredSkinToneIndex];
}

return code;
};

export {
getHeaderEmojis,
mergeEmojisWithFrequentlyUsedEmojis,
Expand Down

0 comments on commit b302017

Please sign in to comment.