From af9fdbaeebd0dff2465a1a4f66f9bb985a8c5a62 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 13 May 2019 14:52:55 +0100 Subject: [PATCH] Rework `reactionsCreated` in `EventTile` to use state This changes to use component state instead of `forceUpdate`, so that it's more obvious why an update is happening here. --- src/components/views/rooms/EventTile.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index b71b28c635..1706019e94 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -182,6 +182,8 @@ module.exports = withMatrixClient(React.createClass({ verified: null, // Whether onRequestKeysClick has been called since mounting. previouslyRequestedKeys: false, + // The Relations model from the JS SDK for reactions to `mxEvent` + reactions: this.getReactions(), }; }, @@ -497,7 +499,9 @@ module.exports = withMatrixClient(React.createClass({ return; } this.props.mxEvent.removeListener("Event.relationsCreated", this._onReactionsCreated); - this.forceUpdate(); + this.setState({ + reactions: this.getReactions(), + }); }, render: function() { @@ -612,11 +616,10 @@ module.exports = withMatrixClient(React.createClass({ } } - const reactions = this.getReactions(); const MessageActionBar = sdk.getComponent('messages.MessageActionBar'); const actionBar = ; }