[TS migration] migrate 'EmojiTrie.js' lib#27693
Conversation
| } | ||
|
|
||
| function createTrie(lang = CONST.LOCALES.DEFAULT) { | ||
| function createTrie(lang: 'en' | 'es' = CONST.LOCALES.DEFAULT): Trie<MetaData> { |
There was a problem hiding this comment.
Could you extract 'en' | 'es' in a separate type?
There was a problem hiding this comment.
@VickyStash See my comment above about SupportedLanguages type.
| */ | ||
| 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.
| 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
|
|
||
| Timing.start(CONST.TIMING.TRIE_INITIALIZATION); | ||
|
|
||
| const supportedLanguages = [CONST.LOCALES.DEFAULT, CONST.LOCALES.ES]; |
There was a problem hiding this comment.
| 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.
| } | ||
|
|
||
| function createTrie(lang = CONST.LOCALES.DEFAULT) { | ||
| function createTrie(lang: 'en' | 'es' = CONST.LOCALES.DEFAULT): Trie<MetaData> { |
There was a problem hiding this comment.
@VickyStash See my comment above about SupportedLanguages type.
| } | ||
|
|
||
| const emojiTrie = _.reduce(supportedLanguages, (prev, cur) => ({...prev, [cur]: createTrie(cur)}), {}); | ||
| const emojiTrie = supportedLanguages.reduce((prev, cur) => ({...prev, [cur]: createTrie(cur)}), {}); |
|
@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.
Just a minor comment about variable names. Otherwise looks good to me.
Who will be doing the reviewer checklist?
| types?: string[]; | ||
| }; | ||
|
|
||
| type LangEmoji = { |
There was a problem hiding this comment.
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.
Sure, I've updated it
| keywords: string[]; | ||
| }; | ||
|
|
||
| type LangEmojis = Record<string, LangEmoji>; |
| name?: string; | ||
| }; | ||
|
|
||
| type MetaData = { |
There was a problem hiding this comment.
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>
blazejkustra
left a comment
There was a problem hiding this comment.
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