From 39bd0d8bb3c357ba15485ad98862a8339a3cc570 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 9 May 2019 18:37:52 +0100 Subject: [PATCH] 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 --- src/components/views/messages/ReactionDimension.js | 6 ++++++ src/components/views/messages/ReactionsRow.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/components/views/messages/ReactionDimension.js b/src/components/views/messages/ReactionDimension.js index f7b43a418c..13d43804ac 100644 --- a/src/components/views/messages/ReactionDimension.js +++ b/src/components/views/messages/ReactionDimension.js @@ -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, diff --git a/src/components/views/messages/ReactionsRow.js b/src/components/views/messages/ReactionsRow.js index a58990a8a5..c49f5cba75 100644 --- a/src/components/views/messages/ReactionsRow.js +++ b/src/components/views/messages/ReactionsRow.js @@ -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,