Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Add primary reactions to action bar#2937

Merged
jryans merged 3 commits intomatrix-org:developfrom
jryans:primary-reactions
May 1, 2019
Merged

Add primary reactions to action bar#2937
jryans merged 3 commits intomatrix-org:developfrom
jryans:primary-reactions

Conversation

@jryans
Copy link
Copy Markdown
Collaborator

@jryans jryans commented Apr 30, 2019

This adds the primary reactions to the action bar. They act as toggles where you
can only select one from each group at a time.

Note that currently we aren't actually sending the reaction at all. That's left
for a separate task.

primary-reactions

Fixes element-hq/element-web#9576

jryans added 3 commits April 30, 2019 17:51
This adds the primary reactions to the action bar. They act as toggles where you
can only select one from each group at a time.

Note that currently we aren't actually sending the reaction at all. That's left
for a separate task.

Fixes element-hq/element-web#9576
Copy link
Copy Markdown
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally lgtm - we may want to consider splitting out the action buttons themselves into simple components to reduce the size of the MessageActionBar component, however that's not really a concern yet.

{
key: "disagree",
content: "👎",
onClick: this.onDisagreeClick,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use the dimension here and bind an onClick to toggleDimensionValue instead of having several pointer functions?

Something like:

{
  key: "disagree",
  content: "👎",
  dimension: "agreeDimension",
}

then in renderReactionDimensionItems:

<span ... onClick={this.toggleDimensionValue.bind(this, option.dimension, option.key)}> ...

Copy link
Copy Markdown
Collaborator Author

@jryans jryans May 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but it's generally suggested that you avoid using inline callbacks or bind in React render methods, since that would create a new function every time, and if that were passed to lower components, it could trigger unnecessary re-rendering.

In this case, we are just rendering spans, not React components for now, so we wouldn't have this issue, but I tend to just avoid doing it everywhere with React, especially since you might later extract some code to a component and not think about this issue.

I think if MessageActionBar gets too complex and/or these functions feel like too much noise, then I think pulling out the reaction dimensions to a new component as you suggested is the correct thing to do.

@jryans jryans merged commit a74824a into matrix-org:develop May 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reactions: Add primary reactions as message actions

2 participants