From 3a16c8a7649c6ee9e8817931b46f25ee192cc3a2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 16 Jun 2015 15:29:13 +0100 Subject: [PATCH] The most important feature --- src/molecules/MessageComposer.js | 19 +++++++++++++++---- src/molecules/MessageTile.js | 3 ++- src/molecules/SenderProfile.js | 5 +++++ 3 files changed, 22 insertions(+), 5 deletions(-) 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}