Page MenuHomePhabricator

[lib] introduce sendReactionMessage to message actions
ClosedPublic

Authored by ginsu on Nov 30 2022, 7:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 8:04 AM
Unknown Object (File)
Sun, Nov 24, 7:53 AM
Unknown Object (File)
Sun, Nov 24, 7:09 AM
Unknown Object (File)
Sun, Nov 24, 6:59 AM
Unknown Object (File)
Sun, Nov 24, 4:27 AM
Unknown Object (File)
Sat, Nov 9, 11:14 PM
Unknown Object (File)
Wed, Nov 6, 7:06 PM
Unknown Object (File)
Wed, Nov 6, 7:06 PM
Subscribers

Details

Summary

introduced sendReactionMessage function to message actions. sendReactionMessage gets all the reaction info from the client and sends that to the reactionMessageCreationResponder and then waits and returns those results


Depends on D5750

Linear Task: ENG-2249

Test Plan

This will be tested further in subsequent diffs. Ran this locally on web/mobile and nothing crashed. Also helped me get to the point where I could push a reaction message into the DB (see screenshot below)

Screenshot 2022-11-28 at 7.16.55 PM.png (2×3 px, 1 MB)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: atul, tomek, rohan.
ginsu requested review of this revision.Nov 30 2022, 7:48 AM

working on message reducer stuff right now and I have a strong intuition that what I return in sendReactionMessage will have to change slightly

replaced time with newMessageInfo in return and created a new type to reflect these changes

lib/actions/message-actions.js
210 ↗(On Diff #19049)

When we allow setting a particular reaction, we should also allow removing just it, and not all the reactions. Setting null doesn't allow that.

lib/actions/message-actions.js
210 ↗(On Diff #19049)

This raises a good question.

I think that we've been working under the assumption that a user can only react to a message with a single reaction (eg iMessage, FB Messenger, Telegram, etc). However, apps like Slack and Discord allow a single user to have multiple reactions to a message.

I think for now we're planning on only letting a user react to a message with a single reaction, but maybe we should consider designing this feature in a flexible way that allows for enabling "multiple reactions" in the future?

Personally think it's fine to proceed as is, but CC @ashoat

lib/actions/message-actions.js
210 ↗(On Diff #19049)

I lean towards what @tomek is saying, better to design an API now that works for that use case...

Not sure how much harder it will be, though. @ginsu what do you think?

lib/actions/message-actions.js
210 ↗(On Diff #19049)

yea I was definitely under the impression that reactions would work similarly to iMessage/FB messenger, but if we want reactions similar to slack/discord, I'm probably going to have to rework a few things. I will talk more with Atul about this in our sync later today

atul requested changes to this revision.EditedDec 1 2022, 2:30 PM

Sending back to your queue to update design as we discussed (include some sort of boolean or enum that describes whether a reaction is being set or "unset")

This revision now requires changes to proceed.Dec 1 2022, 2:30 PM

rebase with unsettingReaction field

tomek added inline comments.
lib/actions/message-actions.js
211 ↗(On Diff #19119)

It's a big improvement - the API is now flexible enough to handle both actions.

But I'm not sure about the name. First of all, unsetting would indicate that we're setting a reaction, but instead we're reacting, so maybe removing is more appropriate?
Inverted logic, where false value means that we're adding a reaction isn't intuitive, but allows us to skip a flag when setting the reaction, so makes some sense.
We can also consider using an object from emoji to boolean flag, but it isn't too useful when we're setting one reaction at a time.

So overall, I'm not sure about the best solution here, but also don't think that it's worth spending a lot of time on it. Maybe finding a little bit better name should be enough.

lib/actions/message-actions.js
211 ↗(On Diff #19119)

Agree we shouldn't waste too much time on this

atul requested changes to this revision.Dec 5 2022, 10:31 AM

Can we quickly update unsettingReaction field to action field that's an enum (eg 'add_reaction' | 'remove_reaction')

lib/actions/message-actions.js
211 ↗(On Diff #19119)

I think unsettingReaction is a weird name for this field.

If we want to keep it as a boolean we could do something like isReactionBeingSet... but then it's not explicit that when false it's unsetting the reaction.

I think it'd be cleaner have a action field that's an enum... something like:

action: 'add_reaction' | 'remove_reaction'

or

action: 'add' | 'remove'

or

action: 'react' | 'unreact'

etc

This revision now requires changes to proceed.Dec 5 2022, 10:31 AM

rebase with action field

lib/actions/message-actions.js
208–211 ↗(On Diff #19145)

Seems like this would be better as an object, so that the parameters are named at the callsite

lib/types/message-types.js
529 ↗(On Diff #19145)

Why do we need this here?

atul requested changes to this revision.Dec 6 2022, 10:58 AM

Requesting changes, agree with @ashoat's feedback

lib/actions/message-actions.js
208–211 ↗(On Diff #19145)

Yeah agree with this.

240 ↗(On Diff #19145)

Do we need interface?

This revision now requires changes to proceed.Dec 6 2022, 10:58 AM
lib/actions/message-actions.js
240 ↗(On Diff #19145)

did a deep dive into call-server-endpoint and came to the conclusion that interface is actually unnecessary for reaction message

lib/types/message-types.js
529 ↗(On Diff #19145)

did a deep dive into call-server-endpoint and came to the conclusion that interface is actually unnecessary for reaction message

This revision is now accepted and ready to land.Dec 9 2022, 2:15 PM