mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Factor out avatar click leads to view_user
This commit is contained in:
parent
6b2aa43b71
commit
d8bc4d9a6f
@ -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 (
|
||||
<BaseAvatar {...otherProps} name={this.state.name} title={this.state.title}
|
||||
idName={member.userId} url={this.state.imageUrl} />
|
||||
idName={member.userId} url={this.state.imageUrl} onClick={onClick}/>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -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 (
|
||||
<MemberAvatar
|
||||
key={e.getId()}
|
||||
member={e.sender}
|
||||
width={14}
|
||||
height={14}
|
||||
onClick={onClickAvatar}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
@ -348,13 +348,6 @@ module.exports = React.createClass({
|
||||
</span>;
|
||||
},
|
||||
|
||||
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({
|
||||
<div className="mx_EventTile_avatar">
|
||||
<MemberAvatar member={this.props.mxEvent.sender}
|
||||
width={avatarSize} height={avatarSize}
|
||||
onClick={ this.onMemberAvatarClick }
|
||||
viewUserOnClick={true}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user