-
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 'EmojiSuggestions.js' component to TypeScript #30416
[TS migration] Migrate 'EmojiSuggestions.js' component to TypeScript #30416
Conversation
if (!item.name) { | ||
return; | ||
} |
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.
Why was this condition removed?
} | ||
}); | ||
emojis | ||
.filter((item: Emoji): item is SimpleEmoji => !(item as HeaderEmoji).header) |
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.
Could you explain the purpose of this filter()?
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.
@fabioh8010 removing of the if condition
and adding of this filter
are related to each other.
emojis
is an array that has one header emoji
{
header: true,
icon: Smiley,
code: 'smileysAndEmotion',
}
and other usual emojis.
Header emoji is not used in emoji suggestions and was filtered out before with a check.
if (!item.name) {
return;
}
I replaced it with a filter instead to add type narrowing to identify that only simple emojis are used in the suggestions.
Btw, before the migration of the EmojiTrie file it also checked for the header field instead of name to filter header emoji out.
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.
Thanks for explanation @VickyStash !
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.
LGTM, maybe let's wait for EmojiUtils PR before proceeding with this PR?
@blazejkustra okay, I'll monitor it |
# Conflicts: # src/components/EmojiSuggestions.tsx # src/components/Text.tsx
@eVoloshchak 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] |
Reviewer Checklist
Screenshots/Videos |
src/components/EmojiSuggestions.tsx
Outdated
<Text | ||
/* eslint-disable-next-line react/no-array-index-key */ | ||
key={`${text}+${i}`} |
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.
This isn't related to this migration and was present before, but still would be nice to fix
We shouldn't use array index in keys, elements should have stable keys when array is filtered/reordered
key={`${text}+${i}`} | |
key={text} |
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.
@eVoloshchak The only concern I have is that potentially, in a rare case, there can be two the same texts.
Maybe will be better to use isColored
as well
key={`${text}+${isColored}`}
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.
The only concern I have is that potentially, in a rare case, there can be two the same texts
There shouldn't be two identical emojis, but it's better to account for such cases, you're right. I like the isColored
idea
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.
Updated!
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.
LGTM
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25045 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
✋ 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/johnmlee101 in version: 1.3.99-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.99-0 🚀
|
🚀 Deployed to staging by https://github.com/johnmlee101 in version: 1.4.0-0 🚀
|
Details
[TS migration] Migrate 'EmojiSuggestions.js' component to TypeScript
Fixed Issues
$ #25045
PROPOSAL: N/A
Tests
:
and the name of the emoji, for example,:love
.Offline tests
N/A
QA Steps
:
and the name of the emoji, for example,:love
.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
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
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop