From 238e967470f56c8182f248ea902594d17e3cebf3 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 21 May 2019 17:23:19 +0100 Subject: [PATCH] Only show reactions in main message timeline This fixes an error that crashed that notifications panel because it was trying to read reactions, even though we currently don't aggregate them there. This change is more explicit about exactly which views should try to show reactions. Fixes https://github.com/vector-im/riot-web/issues/9713 --- src/components/structures/MessagePanel.js | 4 ++++ src/components/structures/RoomView.js | 1 + src/components/structures/TimelinePanel.js | 4 ++++ src/components/views/rooms/EventTile.js | 10 +++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index d61092c051..17e44f2a0f 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -96,6 +96,9 @@ module.exports = React.createClass({ // helper function to access relations for an event getRelationsForEvent: PropTypes.func, + + // whether to show reactions for an event + showReactions: PropTypes.bool, }, componentWillMount: function() { @@ -541,6 +544,7 @@ module.exports = React.createClass({ last={last} isSelectedEvent={highlight} getRelationsForEvent={this.props.getRelationsForEvent} + showReactions={this.props.showReactions} /> , ); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 5f4dc984d0..7c0710a18d 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1832,6 +1832,7 @@ module.exports = React.createClass({ membersLoaded={this.state.membersLoaded} permalinkCreator={this._getPermalinkCreatorForRoom(this.state.room)} resizeNotifier={this.props.resizeNotifier} + showReactions={true} />); let topUnreadMessagesBar = null; diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 7c1afbe9c3..9b4d5200a5 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -106,6 +106,9 @@ const TimelinePanel = React.createClass({ // placeholder text to use if the timeline is empty empty: PropTypes.string, + + // whether to show reactions for an event + showReactions: PropTypes.bool, }, statics: { @@ -1261,6 +1264,7 @@ const TimelinePanel = React.createClass({ resizeNotifier={this.props.resizeNotifier} getRelationsForEvent={this.getRelationsForEvent} editEvent={this.state.editEvent} + showReactions={this.props.showReactions} /> ); }, diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 4b5acf949e..6f0d555d4f 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -160,8 +160,11 @@ module.exports = withMatrixClient(React.createClass({ // show twelve hour timestamps isTwelveHour: PropTypes.bool, - // helper function to access relations for an event + // helper function to access relations for this event getRelationsForEvent: PropTypes.func, + + // whether to show reactions for this event + showReactions: PropTypes.bool, }, getDefaultProps: function() { @@ -198,7 +201,7 @@ module.exports = withMatrixClient(React.createClass({ const client = this.props.matrixClient; client.on("deviceVerificationChanged", this.onDeviceVerificationChanged); this.props.mxEvent.on("Event.decrypted", this._onDecrypted); - if (SettingsStore.isFeatureEnabled("feature_reactions")) { + if (this.props.showReactions && SettingsStore.isFeatureEnabled("feature_reactions")) { this.props.mxEvent.on("Event.relationsCreated", this._onReactionsCreated); } }, @@ -223,7 +226,7 @@ module.exports = withMatrixClient(React.createClass({ const client = this.props.matrixClient; client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged); this.props.mxEvent.removeListener("Event.decrypted", this._onDecrypted); - if (SettingsStore.isFeatureEnabled("feature_reactions")) { + if (this.props.showReactions && SettingsStore.isFeatureEnabled("feature_reactions")) { this.props.mxEvent.removeListener("Event.relationsCreated", this._onReactionsCreated); } }, @@ -485,6 +488,7 @@ module.exports = withMatrixClient(React.createClass({ getReactions() { if ( + !this.props.showReactions || !this.props.getRelationsForEvent || !SettingsStore.isFeatureEnabled("feature_reactions") ) {