-
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
Update frequently used emojis in state whenever its onyx key changes #23965
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you flip this condition and return early, rather than disabling eslint rule?
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.
Done here, thanks for the suggestion.
* Calculate the initial filtered emojis and header row indices | ||
* @returns {Object} | ||
*/ | ||
getInitialFilteredEmojisAndHeaderRowIndices() { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. I couldn't think of a more relevant name 😅, any suggestions?
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.
imo remove initial
from it and should be fine 😆
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, done here
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 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
My bad, this is a mistake. Fixing it.
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 fixed it here, @robertKozik. Sry i missed this and thanks for the spot
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.
Tests well now, let's push this forward
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.
Couple small things. Great collaboration on this PR.
@@ -130,6 +136,31 @@ class EmojiPickerMenu extends Component { | |||
this.setState({selection: event.nativeEvent.selection}); | |||
} | |||
|
|||
/** | |||
* Calculate the initial filtered + header emojis and header row indices |
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.
* 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.
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.
Done
const emojiList = useAnimatedRef(); | ||
const allEmojis = useMemo(() => EmojiUtils.mergeEmojisWithFrequentlyUsedEmojis(emojis), []); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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 explain to me why we need this? I'd just like to understand.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_EMOJIS
in<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 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
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