-
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 'EmojiTrie.js' lib #27693
[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
keywords: string[]; | ||
}; | ||
|
||
type LangEmojis = Record<string, LangEmoji>; | ||
|
||
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
@@ -83,7 +101,7 @@ function createTrie(lang = CONST.LOCALES.DEFAULT) { | |||
return trie; | |||
} | |||
|
|||
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.
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! |
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
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 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.mp4
Mobile Web - Chrome
Web.mobile.android.mp4
Mobile Web - Safari
Web.Mobile.ios.mp4
Desktop
Desktop.mp4
iOS
ios.mp4
Android
Android.mp4