-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[TS migration] migrate 'EmojiTrie.js' lib #27693
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 'EmojiTrie.js' lib #27693
Conversation
src/libs/EmojiTrie.ts
Outdated
| } | ||
|
|
||
| function createTrie(lang = CONST.LOCALES.DEFAULT) { | ||
| function createTrie(lang: 'en' | 'es' = CONST.LOCALES.DEFAULT): Trie<MetaData> { |
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 extract 'en' | 'es' in a separate type?
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.
@VickyStash See my comment above about SupportedLanguages type.
src/libs/EmojiTrie.ts
Outdated
| */ | ||
| function addKeywordsToTrie(trie, keywords, item, name, shouldPrependKeyword = false) { | ||
| _.forEach(keywords, (keyword) => { | ||
| function addKeywordsToTrie(trie: Trie<MetaData>, keywords: string[], item: Emoji, name: string, shouldPrependKeyword = false): void { |
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.
| function addKeywordsToTrie(trie: Trie<MetaData>, keywords: string[], item: Emoji, name: string, shouldPrependKeyword = false): void { | |
| function addKeywordsToTrie(trie: Trie<MetaData>, keywords: string[], item: Emoji, name: string, shouldPrependKeyword = false) { |
When the function don't return anything, we don't need to add void
src/libs/EmojiTrie.ts
Outdated
|
|
||
| Timing.start(CONST.TIMING.TRIE_INITIALIZATION); | ||
|
|
||
| const supportedLanguages = [CONST.LOCALES.DEFAULT, CONST.LOCALES.ES]; |
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.
| const supportedLanguages = [CONST.LOCALES.DEFAULT, CONST.LOCALES.ES]; | |
| const supportedLanguages = [CONST.LOCALES.DEFAULT, CONST.LOCALES.ES] as const; | |
| type SupportedLanguages = (typeof supportedLanguages)[number]; |
We can use SupportedLanguages in createTrie() function.
src/libs/EmojiTrie.ts
Outdated
| } | ||
|
|
||
| function createTrie(lang = CONST.LOCALES.DEFAULT) { | ||
| function createTrie(lang: 'en' | 'es' = CONST.LOCALES.DEFAULT): Trie<MetaData> { |
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.
@VickyStash See my comment above about SupportedLanguages type.
src/libs/EmojiTrie.ts
Outdated
| } | ||
|
|
||
| const emojiTrie = _.reduce(supportedLanguages, (prev, cur) => ({...prev, [cur]: createTrie(cur)}), {}); | ||
| const emojiTrie = supportedLanguages.reduce((prev, cur) => ({...prev, [cur]: createTrie(cur)}), {}); |
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.
rezkiy37
left a comment
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
|
@sobitneupane 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] |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #24870 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
puneetlath
left a comment
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.
Just a minor comment about variable names. Otherwise looks good to me.
Who will be doing the reviewer checklist?
src/libs/EmojiTrie.ts
Outdated
| types?: string[]; | ||
| }; | ||
|
|
||
| type LangEmoji = { |
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'm not a huge fan of this name. I know you're using what was already here, but I think something like localizedEmoji or emojiInLocalLanguage or something like that would be better.
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.
Sure, I've updated it
src/libs/EmojiTrie.ts
Outdated
| keywords: string[]; | ||
| }; | ||
|
|
||
| type LangEmojis = Record<string, LangEmoji>; |
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.
Same comment here.
src/libs/Trie/TrieNode.ts
Outdated
| name?: string; | ||
| }; | ||
|
|
||
| type MetaData = { |
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.
Trie and TrieNode were typed with generic MetaData in mind. So instead of overwriting it here define EmojiMetaData inside of EmojiTrie file and pass it as a generic argument:
// src/libs/EmojiTrie.ts
type Suggestion = {
code: string;
types?: string[];
name?: string;
};
type EmojiMetaData = {
suggestions?: Suggestion[];
};
Trie<MetaData> -> Trie<EmojiMetaData>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
blazejkustra
left a comment
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, SWM still need to do the checklist.
|
Working on the reviewer checklist |
|
I've encountered problems with split money feature but It was not connected with this PR - merging with latest main solves it Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromeandroid.-.web.movMobile Web - SafariiOS.-.web.movDesktopdesktop.moviOSiOS.-.native.movAndroidandroid.-.native.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/puneetlath in version: 1.3.72-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.72-11 🚀
|

Details
Fixed Issues
$ #24870
PROPOSAL: N/A
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.mp4
Mobile Web - Chrome
Web.mobile.android.mp4
Mobile Web - Safari
Web.Mobile.ios.mp4
Desktop
Desktop.mp4
iOS
ios.mp4
Android
Android.mp4