Yay, message sending.

This commit is contained in:
David Baker 2015-06-16 11:08:27 +01:00
parent b2843b09bc
commit 88e9ab02f9
3 changed files with 19 additions and 9 deletions

View file

@ -3,12 +3,22 @@ var React = require('react');
var MatrixClientPeg = require("../MatrixClientPeg");
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
});
this.refs.textarea.getDOMNode().value = '';
ev.preventDefault();
}
},
render: function() {
return (
<div className="mx_MessageComposer">
<form>
<textarea />
</form>
<textarea ref="textarea" onKeyDown={this.onKeyDown} />
</div>
);
},

View file

@ -8,7 +8,7 @@ var MatrixClientPeg = require("../MatrixClientPeg");
module.exports = React.createClass({
getInitialState: function() {
return {
room: MatrixClientPeg.get().getRoom(this.props.room_id)
room: MatrixClientPeg.get().getRoom(this.props.roomId)
}
},
@ -22,14 +22,14 @@ module.exports = React.createClass({
componentWillReceiveProps: function(props) {
this.setState({
room: MatrixClientPeg.get().getRoom(props.room_id)
room: MatrixClientPeg.get().getRoom(props.roomId)
});
},
onRoomTimeline: function(ev, room, toStartOfTimeline) {
if (room.roomId != this.props.room_id) return;
if (room.roomId != this.props.roomId) return;
this.setState({
room: MatrixClientPeg.get().getRoom(this.props.room_id)
room: MatrixClientPeg.get().getRoom(this.props.roomId)
});
},
@ -48,7 +48,7 @@ module.exports = React.createClass({
<ul>
{this.getMessageTiles()}
</ul>
<MessageComposer room={this.state.room} />
<MessageComposer roomId={this.props.roomId} />
</div>
);
},

View file

@ -73,7 +73,7 @@ module.exports = React.createClass({
<MatrixToolbar />
<RoomList selectedRoom={this.state.currentRoom} />
</div>
<RoomView room_id={this.state.currentRoom} />
<RoomView roomId={this.state.currentRoom} />
</div>
);
} else if (this.state.logged_in) {