diff --git a/src/components/views/avatars/MemberAvatar.js b/src/components/views/avatars/MemberAvatar.js index 6e1670604e..5062a35e21 100644 --- a/src/components/views/avatars/MemberAvatar.js +++ b/src/components/views/avatars/MemberAvatar.js @@ -19,6 +19,7 @@ limitations under the License. var React = require('react'); var Avatar = require('../../../Avatar'); var sdk = require("../../../index"); +const dispatcher = require("../../../dispatcher"); module.exports = React.createClass({ displayName: 'MemberAvatar', @@ -27,14 +28,17 @@ module.exports = React.createClass({ member: React.PropTypes.object.isRequired, width: React.PropTypes.number, height: React.PropTypes.number, - resizeMethod: React.PropTypes.string + resizeMethod: React.PropTypes.string, + // Whether the onClick of the avatar should dispatch 'view_user' + viewUserOnClick: React.PropTypes.boolean }, getDefaultProps: function() { return { width: 40, height: 40, - resizeMethod: 'crop' + resizeMethod: 'crop', + viewUserOnClick: false } }, @@ -65,9 +69,19 @@ module.exports = React.createClass({ var {member, ...otherProps} = this.props; + var onClick = null; + if (this.props.viewUserOnClick) { + onClick = () => { + dispatcher.dispatch({ + action: 'view_user', + member: this.props.member, + }); + } + } + return ( + idName={member.userId} url={this.state.imageUrl} onClick={onClick}/> ); } }); diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js index af067dba4b..334d461e48 100644 --- a/src/components/views/elements/MemberEventListSummary.js +++ b/src/components/views/elements/MemberEventListSummary.js @@ -15,7 +15,6 @@ limitations under the License. */ import React from 'react'; const MemberAvatar = require('../avatars/MemberAvatar.js'); -const dispatcher = require("../../../dispatcher"); module.exports = React.createClass({ displayName: 'MemberEventListSummary', @@ -122,19 +121,12 @@ module.exports = React.createClass({ _renderAvatars: function(events) { let avatars = events.slice(0, this.props.avatarsMaxLength).map((e) => { - let onClickAvatar = () => { - dispatcher.dispatch({ - action: 'view_user', - member: e.sender, - }); - }; return ( ); }); diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index fb97d863cd..f4167b32f6 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -348,13 +348,6 @@ module.exports = React.createClass({ ; }, - onMemberAvatarClick: function(event) { - dispatcher.dispatch({ - action: 'view_user', - member: this.props.mxEvent.sender, - }); - }, - onSenderProfileClick: function(event) { var mxEvent = this.props.mxEvent; dispatcher.dispatch({ @@ -443,7 +436,7 @@ module.exports = React.createClass({
);