-
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
import emoji async draft #41097
import emoji async draft #41097
Conversation
src/libs/EmojiTrie.ts
Outdated
@@ -95,9 +95,24 @@ function createTrie(lang: SupportedLanguage = CONST.LOCALES.DEFAULT): Trie<Emoji | |||
return trie; | |||
} | |||
|
|||
const emojiTrie: EmojiTrie = supportedLanguages.reduce((prev, cur) => ({...prev, [cur]: createTrie(cur)}), {}); | |||
// const emojiTrie: 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.
Remove this comment when the PR is ready
src/libs/EmojiTrie.ts
Outdated
const emojiTrie: EmojiTrie = { | ||
en: undefined, | ||
es: undefined, | ||
}; |
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.
Instead of manually creating and maintaining this variable can we consider implementing something like:
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.
That approach I think will create all the tries for "en" and "es" and we want to create them on demand, that's why the idea is to create them manually when it is needed
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.
good point, I added the change so now we create it based on supportedLanguages
variable, thanks!
src/libs/EmojiTrie.ts
Outdated
es: undefined, | ||
}; | ||
|
||
const buildEmojisTrie = (locale: 'en' | '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.
Based on the above comment we might need to tweak the locale 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.
const locales = ['en', 'es'] as const;
type Locale = (typeof locales)[number]; // produces a type of: 'en' | '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.
cc @rinej
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.
adjusted it, used Locale type, thanks!
npm has a |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeScreen.Recording.2024-05-09.at.6.59.07.PM.moviOS: NativeScreen.Recording.2024-05-10.at.5.29.23.PM.moviOS: mWeb SafariScreen.Recording.2024-05-09.at.6.48.27.PM.movMacOS: Chrome / SafariScreen.Recording.2024-05-09.at.6.46.58.PM.movMacOS: DesktopScreen.Recording.2024-05-09.at.7.12.42.PM.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.
Looks good to me!
All yours @mountiny |
Is the failling test related to this? It doesn't look like it. |
Looks like there's no design review needed here as this is mostly a technical solution? |
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.
@rinej Can you please merge main and check out the failing test? I am worried it might be related to the node_options change?
Also can you please update the QA steps to not be a checkbox, but instead a numbered list? Its easier to read and follow. Thank you!
@mouting I did it, I also added the change to fix the failing workflow There was similar issue here -> #40778 (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.
Thanks for the changes
✋ 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/mountiny in version: 1.4.74-0 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.4.74-6 🚀
|
Details
Problem
Currently, both translations for emoji in English (EN) and Spanish (ES) are imported during app initialization. Additionally, we create large objects of EmojiTrie for both languages. The idea is to import and build EmojiTrie only for the currently selected language.
Solution
During app initialization, we check the preferred language and import only that translation file.
We create an EmojiTrie only for that selected language.
If the user changes the language, we will dynamicly import the new translation file and create a new Trie object at that time.
In most cases, users only use one language, so by implementing this change, we can significantly reduce memory consumption and the time needed for creating large EmojiTrie objects.
Some concerns
Jest doesn't support dynamic imports by default. We have to add the flag
--experimental-vm-modules
(https://jestjs.io/docs/ecmascript-modules ) when running jest command (both in GH action and in local package json).Fixed Issues
$ #41893
Tests
Offline tests
QA Steps
:snail
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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.mp4
Android: mWeb Chrome
Android-web.mp4
iOS: Native
iOS.mp4
iOS: mWeb Safari
iOS-web.mp4
MacOS: Chrome / Safari
Web.mp4
MacOS: Desktop
Desktop.mp4