Fix: Size of the single emoji in chat along with updated Emoji Regex#5039
Conversation
|
@deetergp I've added my changes and I am currently testing the coverage of the regex. The initial results look good with few exceptions. |
|
@deetergp PR updated. Please review. |
|
@deetergp PR updated |
deetergp
left a comment
There was a problem hiding this comment.
Looks good, thanks for the changes!
| * Get the unicode code of an emoji in base 16. | ||
| * | ||
| * @name emojiUnicode | ||
| * @function |
There was a problem hiding this comment.
I think we can make these docs more consistent with the others in our app. Notably, @name and @function + the repeated name before the description. We won't find these anywhere so I think better to not use them.
| @@ -0,0 +1,38 @@ | |||
| /* eslint radix: ["error", "as-needed"] */ | |||
There was a problem hiding this comment.
What are we silencing here?
There was a problem hiding this comment.
parseInt also accepts a second param radix, which I've marked as-needed.
There was a problem hiding this comment.
Why not just add the radix?
| } | ||
|
|
||
| if (input.length === 1) { | ||
| return input.charCodeAt(0).toString().split(' ').map(val => parseInt(val).toString(16)) |
| for (let i = 0; i < input.length; i++) { | ||
| if (input.charCodeAt(i) >= 0xd800 && input.charCodeAt(i) <= 0xdbff) { // high surrogate | ||
| if (input.charCodeAt(i + 1) >= 0xdc00 && input.charCodeAt(i + 1) <= 0xdfff) { | ||
| // low surrogate |
There was a problem hiding this comment.
Some of the emojis are stored as two Unicodes. Hence we call each of the Unicode as high surrogate and low surrogate
There was a problem hiding this comment.
Got it thanks. I'm not really familiar with this language - could we maybe add a comment that briefly explains what we mean when we refer to a "surrogate"?
| pairs.push(input.charCodeAt(i)); | ||
| } | ||
| } | ||
| return pairs.map(val => parseInt(val).toString(16)).join(' '); |
| import {showBankAccountFormValidationError, showBankAccountErrorModal} from './actions/BankAccounts'; | ||
| import {translateLocal} from './translate'; | ||
| import getEmojiUnicode from './Emoji/getEmojiUnicode'; | ||
| import trimEmojiUnicode from './Emoji/trimEmojiUnicode'; |
There was a problem hiding this comment.
Probably these could be combined into a single file called EmojiUtils.js or something? We don't enforce one file per method.
| return message.length === matchedEmoji.length; | ||
| const matchedUnicode = getEmojiUnicode(matchedEmoji); | ||
| const currentMessageUnicode = trimEmojiUnicode(getEmojiUnicode(message)); | ||
| return matchedUnicode === currentMessageUnicode; |
There was a problem hiding this comment.
I'm not sure when isSingleEmoji() was added - but it doesn't belongs in this file. ValidationUtils is for validating user input into a form field not to check if something is an emoji. Let's please move it somewhere else.
There was a problem hiding this comment.
Okay should I move it to EmojiUtils, that I'll create for the above functions?
There was a problem hiding this comment.
That works for me! Thanks!
…ngle-emoji-size
…ngle-emoji-size
|
@marcaaron PR updated. |
deetergp
left a comment
There was a problem hiding this comment.
Looking good, thanks for the changes!
| @@ -0,0 +1,76 @@ | |||
| /* eslint radix: ["error", "as-needed"] */ | |||
There was a problem hiding this comment.
I think we can just add the radix here.. is it something other than 10? That's what we do everywhere else.
There was a problem hiding this comment.
Well, with Emojis you can’t be sure that the you’ll get an integer with base 10. This could be because copy pasting emojis from other apps. If you see the code, we are splitting a string and it could start with 0x too.
Added radix.
|
🚀 Deployed to staging by @marcaaron in version: 1.0.97-2 🚀
|
|
This has been deployed to production and is now subject to a 7-day regression period. |
|
🚀 Deployed to production by @francoisl in version: 1.0.98-1 🚀
|


@deetergp I've updated my changes with the regex changes and a unit test to verify all the emojis in our dataset.
Details
isSingleEmojifunctionFixed Issues
$ #4543
Tests
QA Steps
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android