Some checks to see whether stuff is still mounted when adding things.

pull/1/head
David Baker 2015-06-25 17:52:40 +01:00
parent 30a9436485
commit 9aa9a60333
2 changed files with 8 additions and 3 deletions

View File

@ -43,6 +43,7 @@ module.exports = {
componentDidMount: function() {
var that = this;
setTimeout(function() {
if (!that.isMounted()) return;
that.setState({
memberDict: that.roomMembers()
});

View File

@ -61,6 +61,8 @@ module.exports = {
},*/
onRoomTimeline: function(ev, room, toStartOfTimeline) {
if (!this.isMounted()) return;
// ignore anything that comes in whilst pagingating: we get one
// event for each new matrix event so this would cause a huge
// number of UI updates. Just update the UI when the paginate
@ -129,9 +131,11 @@ module.exports = {
var that = this;
MatrixClientPeg.get().scrollback(this.state.room, PAGINATE_SIZE).finally(function() {
that.waiting_for_paginate = false;
if (that.isMounted()) {
that.setState({
room: MatrixClientPeg.get().getRoom(that.props.roomId)
});
}
// wait and set paginating to false when the component updates
});
}