Conversation
src/libs/EmojiTrie.ts
Outdated
| } | ||
|
|
||
| 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.
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.
Instead of manually creating and maintaining this variable can we consider implementing something like:
There was a problem hiding this comment.
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.
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.
Based on the above comment we might need to tweak the locale type.
There was a problem hiding this comment.
const locales = ['en', 'es'] as const;
type Locale = (typeof locales)[number]; // produces a type of: 'en' | 'es';There was a problem hiding this comment.
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 |
|
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? |
mountiny
left a comment
There was a problem hiding this comment.
@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) |
|
✋ 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
:snailPR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.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
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