Skip to content
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

Remove incorrect this from replaceEmojis function #16902

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) => {
Copy link
Contributor

@s77rt s77rt Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we moved the function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeahhh just cuz the linter was upset that we were calling a function before it was declared

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

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