diff --git a/src/controllers/molecules/MessageComposer.js b/src/controllers/molecules/MessageComposer.js index a166cca28e..f55546ae87 100644 --- a/src/controllers/molecules/MessageComposer.js +++ b/src/controllers/molecules/MessageComposer.js @@ -54,7 +54,11 @@ module.exports = { }; } - MatrixClientPeg.get().sendMessage(this.props.roomId, content); + MatrixClientPeg.get().sendMessage(this.props.roomId, content).then(function() { + dis.dispatch({ + action: 'message_sent' + }); + }); this.refs.textarea.getDOMNode().value = ''; ev.preventDefault(); } diff --git a/src/controllers/organisms/RoomView.js b/src/controllers/organisms/RoomView.js index cfe4dfd099..9550fda781 100644 --- a/src/controllers/organisms/RoomView.js +++ b/src/controllers/organisms/RoomView.js @@ -18,6 +18,8 @@ limitations under the License. var MatrixClientPeg = require("../../MatrixClientPeg"); +var dis = require("../../dispatcher"); + var PAGINATE_SIZE = 20; module.exports = { @@ -28,16 +30,28 @@ module.exports = { }, componentWillMount: function() { + this.dispatcherRef = dis.register(this.onAction); MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline); this.atBottom = true; }, componentWillUnmount: function() { + dis.unregister(this.dispatcherRef); if (MatrixClientPeg.get()) { MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline); } }, + onAction: function(payload) { + switch (payload.action) { + case 'message_sent': + this.setState({ + room: MatrixClientPeg.get().getRoom(this.props.roomId) + }); + break; + } + }, + // MatrixRoom still showing the messages from the old room? // Set the key to the room_id. Sadly you can no longer get at // the key from inside the component, or we'd check this in code.