Browse Source

Yay, message sending.

pull/1/head
David Baker 7 years ago
parent
commit
88e9ab02f9
  1. 16
      src/molecules/MessageComposer.js
  2. 10
      src/organisms/RoomView.js
  3. 2
      src/pages/MatrixChat.js

16
src/molecules/MessageComposer.js

@ -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>
);
},

10
src/organisms/RoomView.js

@ -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>
);
},

2
src/pages/MatrixChat.js

@ -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) {

Loading…
Cancel
Save