-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[TS migration] Migrate 'EmojiUtils.js' lib to TypeScript #28589
[TS migration] Migrate 'EmojiUtils.js' lib to TypeScript #28589
Conversation
@blazejkustra please review this before it goes off to callstack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see Frequently Used emojis
Screen.Recording.2023-10-27.at.6.33.36.PM.mov
src/libs/EmojiUtils.ts
Outdated
if (matching.length === limit) { | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial value is missing in reduce 2nd param. This leads to crash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the initial value, can you tell me what have you done to crash the app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 {users, oldestTimestamp} = enrichEmojiReactionWithTimestamps(reaction, emojiName); | ||
|
||
const emoji = findEmojiByName(emojiName); | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map((user) => Object.values(user.skinTones).length) | |
.map((user) => Object.values(user.skinTones ?? {}).length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crash doesn't happen anymore after this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
✋ 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 🚀
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
ios.mov
Android
android.mov