Browse Source

The most important feature

pull/1/head
David Baker 7 years ago
parent
commit
3a16c8a764
  1. 19
      src/molecules/MessageComposer.js
  2. 3
      src/molecules/MessageTile.js
  3. 5
      src/molecules/SenderProfile.js

19
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();
}

3
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({

5
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 (
<span className="mx_SenderProfile">
{name}

Loading…
Cancel
Save