From 2355d5e6b595fb426aa35c5001178eff255523f4 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 24 Jun 2015 18:15:34 +0100 Subject: [PATCH] Fix the permagrey local-echo bug --- src/controllers/molecules/MessageComposer.js | 6 +++++- src/controllers/organisms/RoomView.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/controllers/molecules/MessageComposer.js b/src/controllers/molecules/MessageComposer.js index a166cca2..f55546ae 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 cfe4dfd0..9550fda7 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.