Fix the permagrey local-echo bug

This commit is contained in:
David Baker 2015-06-24 18:15:34 +01:00
parent e5a4e5b195
commit 2355d5e6b5
2 changed files with 19 additions and 1 deletions

View file

@ -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 = ''; this.refs.textarea.getDOMNode().value = '';
ev.preventDefault(); ev.preventDefault();
} }

View file

@ -18,6 +18,8 @@ limitations under the License.
var MatrixClientPeg = require("../../MatrixClientPeg"); var MatrixClientPeg = require("../../MatrixClientPeg");
var dis = require("../../dispatcher");
var PAGINATE_SIZE = 20; var PAGINATE_SIZE = 20;
module.exports = { module.exports = {
@ -28,16 +30,28 @@ module.exports = {
}, },
componentWillMount: function() { componentWillMount: function() {
this.dispatcherRef = dis.register(this.onAction);
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline); MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
this.atBottom = true; this.atBottom = true;
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
dis.unregister(this.dispatcherRef);
if (MatrixClientPeg.get()) { if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline); 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? // MatrixRoom still showing the messages from the old room?
// Set the key to the room_id. Sadly you can no longer get at // 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. // the key from inside the component, or we'd check this in code.