diff --git a/src/molecules/MessageComposer.js b/src/molecules/MessageComposer.js index f3a554ff..61946252 100644 --- a/src/molecules/MessageComposer.js +++ b/src/molecules/MessageComposer.js @@ -6,10 +6,21 @@ module.exports = React.createClass({ onKeyDown: function (ev) { if (ev.keyCode == 13) { var contentText = this.refs.textarea.getDOMNode().value; - MatrixClientPeg.get().sendMessage(this.props.roomId, { - msgtype: 'm.text', - body: contentText - }); + + var content = null; + if (/^\/me /i.test(contentText)) { + content = { + msgtype: 'm.emote', + body: contentText.substring(4) + }; + } else { + content = { + msgtype: 'm.text', + body: contentText + }; + } + + MatrixClientPeg.get().sendMessage(this.props.roomId, content); this.refs.textarea.getDOMNode().value = ''; ev.preventDefault(); } diff --git a/src/molecules/MessageTile.js b/src/molecules/MessageTile.js index 74d42a9a..dd1ab38f 100644 --- a/src/molecules/MessageTile.js +++ b/src/molecules/MessageTile.js @@ -6,7 +6,8 @@ var SenderProfile = require('../molecules/SenderProfile'); var UnknownMessageTile = require('../molecules/UnknownMessageTile'); var tileTypes = { - 'm.text': require('../molecules/MTextTile') + 'm.text': require('../molecules/MTextTile'), + 'm.emote': require('../molecules/MEmoteTile') }; module.exports = React.createClass({ diff --git a/src/molecules/SenderProfile.js b/src/molecules/SenderProfile.js index 517233c1..d7cd1f38 100644 --- a/src/molecules/SenderProfile.js +++ b/src/molecules/SenderProfile.js @@ -4,6 +4,11 @@ module.exports = React.createClass({ render: function() { var mxEvent = this.props.mxEvent; var name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender(); + + var msgtype = mxEvent.getContent().msgtype; + if (msgtype && msgtype == 'm.emote') { + name = ''; // emote message must include the name so don't duplicate it + } return ( {name}