click on nicks to insert them into the MessageComposer

This commit is contained in:
Matthew Hodgson 2016-03-17 15:35:23 +00:00
parent a13513935b
commit c7ffb59374
2 changed files with 20 additions and 4 deletions

View file

@ -268,10 +268,17 @@ module.exports = React.createClass({
this.readAvatarNode = ReactDom.findDOMNode(node);
},
onMemberAvatarClicked: function(sender) {
onMemberAvatarClick: function(event) {
dispatcher.dispatch({
action: 'view_user',
member: sender
member: this.props.mxEvent.sender,
});
},
onSenderProfileClick: function(event) {
dispatcher.dispatch({
action: 'insert_displayname',
displayname: this.props.mxEvent.sender.name,
});
},
@ -318,12 +325,12 @@ module.exports = React.createClass({
avatar = (
<div className="mx_EventTile_avatar">
<MemberAvatar member={this.props.mxEvent.sender} width={24} height={24}
onClick={ this.onMemberAvatarClicked.bind(this, this.props.mxEvent.sender) } />
onClick={ this.onMemberAvatarClick } />
</div>
);
}
if (EventTileType.needsSenderProfile()) {
sender = <SenderProfile mxEvent={this.props.mxEvent} aux={aux} />;
sender = <SenderProfile onClick={ this.onSenderProfileClick } mxEvent={this.props.mxEvent} aux={aux} />;
}
}
return (

View file

@ -196,6 +196,15 @@ module.exports = React.createClass({
case 'focus_composer':
this.refs.textarea.focus();
break;
case 'insert_displayname':
if (this.refs.textarea.value) {
this.refs.textarea.value =
this.refs.textarea.value.replace(/( ?)$/, " " + payload.displayname);
}
else {
this.refs.textarea.value = payload.displayname + ": ";
}
break;
}
},