[TS migration] Migrate 'EmojiUtils.js' lib to TypeScript#28589
[TS migration] Migrate 'EmojiUtils.js' lib to TypeScript#28589francoisl merged 18 commits intoExpensify:mainfrom
Conversation
|
@blazejkustra please review this before it goes off to callstack |
kubabutkiewicz
left a comment
There was a problem hiding this comment.
one small comment , but LGTM
|
@0xmiroslav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
blazejkustra
left a comment
There was a problem hiding this comment.
One small comment, let's add more detailed Tests and QA Steps @BartoszGrajdek
|
@0xmiroslav bump |
|
Taking this over based on @0xmiroslav's request |
|
@situchan we would greatly appreciate it if you could work on the reviewer's checklist today. This PR blocks other migration PR. |
|
Sure. Reviewing now |
situchan
left a comment
There was a problem hiding this comment.
I don't see Frequently Used emojis
Screen.Recording.2023-10-27.at.6.33.36.PM.mov
src/libs/EmojiUtils.ts
Outdated
| return matching; | ||
| } | ||
| matching.push({code: nodes[j].metaData.code, name: nodes[j].name, types: nodes[j].metaData.types}); | ||
| matching.push({code: node.metaData?.code ?? '', name: node.name, types: node.metaData.types}); |
There was a problem hiding this comment.
Already have this check - node.metaData.code && in if condition
| matching.push({code: node.metaData?.code ?? '', name: node.name, types: node.metaData.types}); | |
| matching.push({code: node.metaData.code, name: node.name, types: node.metaData.types}); |
|
I noticed that above bug also happens on main. So not able to verify this PR didn't cause any issue with Frequently Used emojis. |
|
I can confirm that manually typing emoji in composer works and added to recent list web2.mov |
src/libs/EmojiUtils.ts
Outdated
| const usersWithTimestamps: Record<string, UserReactionsWithTimestamps> = {}; | ||
| Object.keys(emoji.users ?? {}).forEach((id) => { | ||
| const user = emoji?.users?.[id]; | ||
| const oldestUserTimestamp = Object.values(user?.skinTones ?? {}).reduce((min, curr) => (curr < min ? curr : min)); |
There was a problem hiding this comment.
initial value is missing in reduce 2nd param. This leads to crash
There was a problem hiding this comment.
I've added the initial value, can you tell me what have you done to crash the app?
|
Above crash is replaced with this one after last commit: Screen.Recording.2023-11-07.at.5.36.04.PM.mov |
Working on it, however cannot reproduce yet |
|
It's interesting that crash happens only on my android emulator. |
|
I managed to reproduce this error, or similar one on web. @BartoszGrajdek is investigating 👍 |
|
Alright, the error that Błażej reproduced wasn't the one you've seen @situchan Could you please provide some reproduction steps? Also is it only happening on this branch, or is it on main as well? |
Only this branch. Not happening on main Can you fix based on log I shared above? I can test here. |
|
I've added a quick fix, however if this doesn't work we will need some clear reproduction steps unfortunately. Let us know how it works out @situchan |
src/libs/EmojiUtils.ts
Outdated
| const emojiCodes = getUniqueEmojiCodes(emoji, users); | ||
| const reactionCount = lodashSum(_.map(users, (user) => _.size(user.skinTones))); | ||
| const reactionCount = Object.values(users) | ||
| .map((user) => Object.values(user.skinTones).length) |
There was a problem hiding this comment.
| .map((user) => Object.values(user.skinTones).length) | |
| .map((user) => Object.values(user.skinTones ?? {}).length) |
There was a problem hiding this comment.
Crash doesn't happen anymore after this change
There was a problem hiding this comment.
Done! I've also added this in a few other places, to make sure that potential undefined are handled.
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/francoisl in version: 1.3.96-6 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀
|
|
🚀 Deployed to staging by https://github.com/francoisl in version: 1.3.98-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.98-5 🚀
|
| callback: (val) => { | ||
| frequentlyUsedEmojis = _.map(val, (item) => { | ||
| const emoji = Emojis.emojiCodeTableWithSkinTones[item.code]; | ||
| if (emoji) { | ||
| return {...emoji, count: item.count, lastUpdatedAt: item.lastUpdatedAt}; | ||
| } | ||
| }); | ||
| if (!val) { | ||
| return; | ||
| } | ||
| frequentlyUsedEmojis = | ||
| val | ||
| ?.map((item) => { | ||
| const emoji = Emojis.emojiCodeTableWithSkinTones[item.code]; | ||
| return {...emoji, count: item.count, lastUpdatedAt: item.lastUpdatedAt}; | ||
| }) | ||
| .filter((emoji): emoji is FrequentlyUsedEmoji => !!emoji) ?? []; | ||
| }, | ||
| }); |
There was a problem hiding this comment.
FYI, removing if (emoji) condition in this PR caused #45354
More details in this proposal: #45354 (comment)




Details
Migrate EmojiUtils lib & assets to typescript
Fixed Issues
$ #24899
$ #24733
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
ios.mov
Android
android.mov