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 https://github.com/vector-im/riot-web/issues/9572
pull/21833/head
J. Ryan Stinnett 2019-05-09 18:37:52 +01:00
parent 37d2f60045
commit 39bd0d8bb3
2 changed files with 12 additions and 0 deletions

View File

@ -37,18 +37,24 @@ export default class ReactionDimension extends React.PureComponent {
};
if (props.reactions) {
props.reactions.on("Relations.add", this.onReactionsChange);
props.reactions.on("Relations.redaction", this.onReactionsChange);
}
}
componentWillReceiveProps(nextProps) {
if (this.props.reactions !== nextProps.reactions) {
nextProps.reactions.on("Relations.add", this.onReactionsChange);
nextProps.reactions.on("Relations.redaction", this.onReactionsChange);
}
}
componentWillUnmount() {
if (this.props.reactions) {
this.props.reactions.removeListener(
"Relations.add",
this.onReactionsChange,
);
this.props.reactions.removeListener(
"Relations.redaction",
this.onReactionsChange,

View File

@ -32,18 +32,24 @@ export default class ReactionsRow extends React.PureComponent {
super(props);
if (props.reactions) {
props.reactions.on("Relations.add", this.onReactionsChange);
props.reactions.on("Relations.redaction", this.onReactionsChange);
}
}
componentWillReceiveProps(nextProps) {
if (this.props.reactions !== nextProps.reactions) {
nextProps.reactions.on("Relations.add", this.onReactionsChange);
nextProps.reactions.on("Relations.redaction", this.onReactionsChange);
}
}
componentWillUnmount() {
if (this.props.reactions) {
this.props.reactions.removeListener(
"Relations.add",
this.onReactionsChange,
);
this.props.reactions.removeListener(
"Relations.redaction",
this.onReactionsChange,