Factor out avatar click leads to view_user
This commit is contained in:
parent
6b2aa43b71
commit
d8bc4d9a6f
3 changed files with 18 additions and 19 deletions
|
@ -19,6 +19,7 @@ limitations under the License.
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var Avatar = require('../../../Avatar');
|
var Avatar = require('../../../Avatar');
|
||||||
var sdk = require("../../../index");
|
var sdk = require("../../../index");
|
||||||
|
const dispatcher = require("../../../dispatcher");
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MemberAvatar',
|
displayName: 'MemberAvatar',
|
||||||
|
@ -27,14 +28,17 @@ module.exports = React.createClass({
|
||||||
member: React.PropTypes.object.isRequired,
|
member: React.PropTypes.object.isRequired,
|
||||||
width: React.PropTypes.number,
|
width: React.PropTypes.number,
|
||||||
height: 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() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
resizeMethod: 'crop'
|
resizeMethod: 'crop',
|
||||||
|
viewUserOnClick: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -65,9 +69,19 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var {member, ...otherProps} = this.props;
|
var {member, ...otherProps} = this.props;
|
||||||
|
|
||||||
|
var onClick = null;
|
||||||
|
if (this.props.viewUserOnClick) {
|
||||||
|
onClick = () => {
|
||||||
|
dispatcher.dispatch({
|
||||||
|
action: 'view_user',
|
||||||
|
member: this.props.member,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseAvatar {...otherProps} name={this.state.name} title={this.state.title}
|
<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';
|
import React from 'react';
|
||||||
const MemberAvatar = require('../avatars/MemberAvatar.js');
|
const MemberAvatar = require('../avatars/MemberAvatar.js');
|
||||||
const dispatcher = require("../../../dispatcher");
|
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MemberEventListSummary',
|
displayName: 'MemberEventListSummary',
|
||||||
|
@ -122,19 +121,12 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_renderAvatars: function(events) {
|
_renderAvatars: function(events) {
|
||||||
let avatars = events.slice(0, this.props.avatarsMaxLength).map((e) => {
|
let avatars = events.slice(0, this.props.avatarsMaxLength).map((e) => {
|
||||||
let onClickAvatar = () => {
|
|
||||||
dispatcher.dispatch({
|
|
||||||
action: 'view_user',
|
|
||||||
member: e.sender,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<MemberAvatar
|
<MemberAvatar
|
||||||
key={e.getId()}
|
key={e.getId()}
|
||||||
member={e.sender}
|
member={e.sender}
|
||||||
width={14}
|
width={14}
|
||||||
height={14}
|
height={14}
|
||||||
onClick={onClickAvatar}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -348,13 +348,6 @@ module.exports = React.createClass({
|
||||||
</span>;
|
</span>;
|
||||||
},
|
},
|
||||||
|
|
||||||
onMemberAvatarClick: function(event) {
|
|
||||||
dispatcher.dispatch({
|
|
||||||
action: 'view_user',
|
|
||||||
member: this.props.mxEvent.sender,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onSenderProfileClick: function(event) {
|
onSenderProfileClick: function(event) {
|
||||||
var mxEvent = this.props.mxEvent;
|
var mxEvent = this.props.mxEvent;
|
||||||
dispatcher.dispatch({
|
dispatcher.dispatch({
|
||||||
|
@ -443,7 +436,7 @@ module.exports = React.createClass({
|
||||||
<div className="mx_EventTile_avatar">
|
<div className="mx_EventTile_avatar">
|
||||||
<MemberAvatar member={this.props.mxEvent.sender}
|
<MemberAvatar member={this.props.mxEvent.sender}
|
||||||
width={avatarSize} height={avatarSize}
|
width={avatarSize} height={avatarSize}
|
||||||
onClick={ this.onMemberAvatarClick }
|
viewUserOnClick={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue