Page MenuHomePhabricator

[lib/native] introduce getViewerAlreadySelectedMessageReactions
ClosedPublic

Authored by ginsu on Jun 21 2023, 4:08 PM.
Tags
None
Referenced Files
F3870080: D8288.diff
Wed, Jan 22, 9:20 PM
Unknown Object (File)
Mon, Jan 13, 1:42 PM
Unknown Object (File)
Fri, Jan 10, 1:55 AM
Unknown Object (File)
Thu, Jan 9, 1:07 PM
Unknown Object (File)
Wed, Jan 1, 2:37 AM
Unknown Object (File)
Wed, Jan 1, 2:37 AM
Unknown Object (File)
Wed, Jan 1, 2:37 AM
Unknown Object (File)
Wed, Jan 1, 2:37 AM
Subscribers

Details

Summary

This diff is the second part to highlight the already selected emojis to indicate on the emoji keyboard what emojis the user has already selected. This diff handles the case when selectMultipleEmojis is equal to true.

To handle this case we need to iterate through the ReactionInfo map and return an array of emojis that the user has already selected. I introduced a separate helper function called getViewerAlreadySelectedMessageReactions since MultimediaMessageTooltipButton, TextMessageTooltipButton and RobotextMessageTooltipButton will all need to do this similar functionality.

Here is a link to an example to the docs that helped me with this implementation: https://thewidlarzgroup.github.io/rn-emoji-keyboard/docs/documentation/Examples/selected_emojis

Linear Task: https://linear.app/comm/issue/ENG-3794/mobile-emoji-keyboard-highlight-emojis-that-a-user-has-already

Depends on D8284

Test Plan

Please watch the demo video below:

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu requested review of this revision.Jun 21 2023, 4:25 PM
ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: atul, kamil.
ginsu added inline comments.
native/components/emoji-keyboard.react.js
63–68 ↗(On Diff #27987)

These additional cases were inspired from this example in the rn-emoji-keyboard docs

native/chat/multimedia-message-tooltip-button.react.js
158–161 ↗(On Diff #27987)

I was wondering, how about creating a hook/state that will contain an array of emojis and add/remove emoji while calling onEmojiSelected instead of recalculating this on each item.reactionschange (even if viewerReacted is false)?

I am not familiar with all parts of this logic, so curious how hard this will be to implement and if we will gain anything from this.

native/chat/multimedia-message-tooltip-button.react.js
158–161 ↗(On Diff #27987)

I don't think this is possible, because this component is actually part of a modal component (RobotextMessageTooltipModal, TextMessageTooltipModal, MultimediaMessageTooltipModal. This means that when we close the modal/go back we will unmount this screen and the state for this component will get thrown away. I found this blurb in the react-navigation docs that might offer more context:

https://reactnavigation.org/docs/hello-react-navigation/#configuring-the-navigator:~:text=or%20your%20component%20will%20unmount%20and%20remount%20losing%20all%20state

kamil added inline comments.
native/chat/multimedia-message-tooltip-button.react.js
158–161 ↗(On Diff #27987)

ahh right, thanks!

This revision is now accepted and ready to land.Jun 23 2023, 2:09 AM
This revision was landed with ongoing or failed builds.Jun 23 2023, 1:12 PM
This revision was automatically updated to reflect the committed changes.
native/chat/text-message-tooltip-button.react.js
155–158

You could have avoided copy-pasting this block three times if you had defined a hook (eg. useViewerAlreadySelectedMessageReactions) instead of defining a utility function

native/chat/text-message-tooltip-button.react.js
155–158