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

Commit 39bd0d8

Browse files
committed
Listen for additional reactions in existing collection
The various reaction UI bits will now listen for `Reactions.add` for new reactions just like with redactions. Part of element-hq/element-web#9572
1 parent 37d2f60 commit 39bd0d8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/components/views/messages/ReactionDimension.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,24 @@ export default class ReactionDimension extends React.PureComponent {
3737
};
3838

3939
if (props.reactions) {
40+
props.reactions.on("Relations.add", this.onReactionsChange);
4041
props.reactions.on("Relations.redaction", this.onReactionsChange);
4142
}
4243
}
4344

4445
componentWillReceiveProps(nextProps) {
4546
if (this.props.reactions !== nextProps.reactions) {
47+
nextProps.reactions.on("Relations.add", this.onReactionsChange);
4648
nextProps.reactions.on("Relations.redaction", this.onReactionsChange);
4749
}
4850
}
4951

5052
componentWillUnmount() {
5153
if (this.props.reactions) {
54+
this.props.reactions.removeListener(
55+
"Relations.add",
56+
this.onReactionsChange,
57+
);
5258
this.props.reactions.removeListener(
5359
"Relations.redaction",
5460
this.onReactionsChange,

src/components/views/messages/ReactionsRow.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@ export default class ReactionsRow extends React.PureComponent {
3232
super(props);
3333

3434
if (props.reactions) {
35+
props.reactions.on("Relations.add", this.onReactionsChange);
3536
props.reactions.on("Relations.redaction", this.onReactionsChange);
3637
}
3738
}
3839

3940
componentWillReceiveProps(nextProps) {
4041
if (this.props.reactions !== nextProps.reactions) {
42+
nextProps.reactions.on("Relations.add", this.onReactionsChange);
4143
nextProps.reactions.on("Relations.redaction", this.onReactionsChange);
4244
}
4345
}
4446

4547
componentWillUnmount() {
4648
if (this.props.reactions) {
49+
this.props.reactions.removeListener(
50+
"Relations.add",
51+
this.onReactionsChange,
52+
);
4753
this.props.reactions.removeListener(
4854
"Relations.redaction",
4955
this.onReactionsChange,

0 commit comments

Comments
 (0)