diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index d21dbd88da..b5a429a366 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -16,6 +16,8 @@ limitations under the License. import React from 'react'; import ReactDOM from 'react-dom'; +import UserSettingsStore from '../../UserSettingsStore'; +import shouldHideEvent from '../../shouldHideEvent'; import dis from "../../dispatcher"; import sdk from '../../index'; @@ -90,12 +92,6 @@ module.exports = React.createClass({ // show timestamps always alwaysShowTimestamps: React.PropTypes.bool, - - // hide redacted events as per old behaviour - hideRedactions: React.PropTypes.bool, - - // hide membership joins and parts - hideJoinLeaves: React.PropTypes.bool, }, componentWillMount: function() { @@ -116,6 +112,8 @@ module.exports = React.createClass({ // Velocity requires this._readMarkerGhostNode = null; + this._syncedSettings = UserSettingsStore.getSyncedSettings(); + this._isMounted = true; }, @@ -252,37 +250,7 @@ module.exports = React.createClass({ // Always show highlighted event if (this.props.highlightedEventId === mxEv.getId()) return true; - // Hide redactions if behaviour enabled - if (mxEv.isRedacted() && this.props.hideRedactions) return false; - - const isMemberEvent = mxEv.getType() === "m.room.member" && mxEv.getStateKey() !== undefined; - if (!isMemberEvent) { - return true; // bail early: all the checks below concern member events only - } - - // TODO: These checks are done to make sure we're dealing with membership transitions not avatar changes / dupe joins - // These checks are also being done in TextForEvent and should really reside in the JS SDK as a helper function - const membership = mxEv.getContent().membership; - const prevMembership = mxEv.getPrevContent().membership; - if (membership === prevMembership && membership === "join") { - // join -> join : This happens when display names change / avatars are set / genuine dupe joins with no changes. - // Find out which we're dealing with. - if (mxEv.getPrevContent().displayname !== mxEv.getContent().displayname) { - return true; // display name changed - } - if (mxEv.getPrevContent().avatar_url !== mxEv.getContent().avatar_url) { - return true; // avatar url changed - } - // dupe join event, fall through to hide rules - } - - // this only applies to joins/leaves not invites/kicks/bans - const isJoinOrLeave = membership === "join" || (membership === "leave" && mxEv.getStateKey() === mxEv.getSender()); - const hideJoinLeavesGlobally = this.props.hideJoinLeaves; - if (isJoinOrLeave && hideJoinLeavesGlobally) { - return false; - } - return true; + return !shouldHideEvent(mxEv, this._syncedSettings); }, _getEventTiles: function() {