Update frequently used emojis in state whenever its onyx key changes#23965
Conversation
|
@robertKozik 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] |
|
There were some merge conflicts, the native emoji picker menu was migrated to function component. @robertKozik bump for review. |
robertKozik
left a comment
There was a problem hiding this comment.
Minor requests, overally great job 🚀
| // eslint-disable-next-line rulesdir/prefer-early-return | ||
| componentDidUpdate(prevProps) { | ||
| if (prevProps.frequentlyUsedEmojis !== this.props.frequentlyUsedEmojis) { | ||
| const {filteredEmojis, headerRowIndices} = this.getInitialFilteredEmojisAndHeaderRowIndices(); | ||
| this.emojis = filteredEmojis; | ||
| this.headerRowIndices = headerRowIndices; | ||
| this.setState({ | ||
| filteredEmojis: this.emojis, | ||
| headerIndices: this.headerRowIndices, | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Can you flip this condition and return early, rather than disabling eslint rule?
| * Calculate the initial filtered emojis and header row indices | ||
| * @returns {Object} | ||
| */ | ||
| getInitialFilteredEmojisAndHeaderRowIndices() { |
There was a problem hiding this comment.
As this method is not only calculated the emojis and indices on initial render, can we change the name to be more appropriate?
There was a problem hiding this comment.
sure. I couldn't think of a more relevant name 😅, any suggestions?
There was a problem hiding this comment.
imo remove initial from it and should be fine 😆
|
Thanks for the feedback @robertKozik. I have applied the suggested changes! |
|
@robertKozik bumping for review. |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromeandroid-web.movMobile Web - SafariiOS-web.movDesktopdesktop.moviOSiOS.-.native.movAndroidandroid-native.mov |
|
Minor things according to author checklist @huzaifa-99 :
In the meantime I'll record the videos |
|
Ah missed those. Thanks, @robertKozik
on it. |
Done @robertKozik. Thanks |
robertKozik
left a comment
There was a problem hiding this comment.
One regression which I encounter after tests
|
|
||
| // Get the header emojis along with the code, index and icon. | ||
| // index is the actual header index starting at the first emoji and counting each one | ||
| this.headerEmojis = EmojiUtils.getHeaderEmojis(this.emojis); |
There was a problem hiding this comment.
Did you delete this assignment entirely? I see you are calculating it inside ComponentDidUpdate but there is no assignment to this.headerEmojis there. I see it's used in CategoryShortcutBar, and because of that it's not visible now
There was a problem hiding this comment.
My bad, this is a mistake. Fixing it.
There was a problem hiding this comment.
I fixed it here, @robertKozik. Sry i missed this and thanks for the spot
robertKozik
left a comment
There was a problem hiding this comment.
Tests well now, let's push this forward
puneetlath
left a comment
There was a problem hiding this comment.
Couple small things. Great collaboration on this PR.
| } | ||
|
|
||
| /** | ||
| * Calculate the initial filtered + header emojis and header row indices |
There was a problem hiding this comment.
| * Calculate the initial filtered + header emojis and header row indices | |
| * Calculate the filtered + header emojis and header row indices |
It looks like this function is used any time the component updates, not just initially.
| function EmojiPickerMenu({preferredLocale, onEmojiSelected, preferredSkinTone, translate, frequentlyUsedEmojis}) { | ||
| const emojiList = useAnimatedRef(); | ||
| const allEmojis = useMemo(() => EmojiUtils.mergeEmojisWithFrequentlyUsedEmojis(emojis), []); | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Could you explain to me why we need this? I'd just like to understand.
There was a problem hiding this comment.
We are calculating allEmojis whenever frequentlyUsedEmojis are changing. Since we are not directly using the frequentlyUsedEmojis value in the memo hook, it gives lint error.
The EmojiUtils.mergeEmojisWithFrequentlyUsedEmojis() function uses the frequentlyUsedEmojis value internally by subscribing to onyx in EmojiUtils.
There was a problem hiding this comment.
Got it! Thanks for the explanation.
|
Thanks for the feedback @puneetlath. I have applied the suggested 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. |
|
TYSM guys 🚀 |
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.3.50-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.50-3 🚀
|
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.3.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 1.3.51-2 🚀
|


Details
We were not recalculating the frequently used emojis list in the Emoji picker when it was already opened and the frequently used emojis got updated in another device.
With these changes, we are now listening to the onyx key
ONYXKEYS.FREQUENTLY_USED_EMOJISin<EmojiPickerMenu/>and updating the already rendered emojis list when its changes from a different device.Fixed Issues
$ #23800
PROPOSAL: #23800 (comment)
Tests
Offline tests
QA Steps
Same as "Tests" section above
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
Chrome:
Web.Chrome.and.Safari.mp4
Safari:
Web.Chrome.and.Safari.mp4
Mobile Web - Chrome
IOS.Safari.and.mWeb.Chrome.mp4
Mobile Web - Safari
IOS.Safari.and.mWeb.Chrome.mp4
Desktop
IOS.Native.and.Desktop.Native.mp4
iOS
IOS.Native.and.Desktop.Native.mp4
Android
Android.Native.and.Desktop.Native.mp4