From 9aa9a603331ea1e1ab03ffba2420587cad4d0ec8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 25 Jun 2015 17:52:40 +0100 Subject: [PATCH] Some checks to see whether stuff is still mounted when adding things. --- src/controllers/organisms/MemberList.js | 1 + src/controllers/organisms/RoomView.js | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/controllers/organisms/MemberList.js b/src/controllers/organisms/MemberList.js index 7d188b6ca3..a511816d53 100644 --- a/src/controllers/organisms/MemberList.js +++ b/src/controllers/organisms/MemberList.js @@ -43,6 +43,7 @@ module.exports = { componentDidMount: function() { var that = this; setTimeout(function() { + if (!that.isMounted()) return; that.setState({ memberDict: that.roomMembers() }); diff --git a/src/controllers/organisms/RoomView.js b/src/controllers/organisms/RoomView.js index d2fec9d900..b3ea6666a4 100644 --- a/src/controllers/organisms/RoomView.js +++ b/src/controllers/organisms/RoomView.js @@ -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; - that.setState({ - room: MatrixClientPeg.get().getRoom(that.props.roomId) - }); + if (that.isMounted()) { + that.setState({ + room: MatrixClientPeg.get().getRoom(that.props.roomId) + }); + } // wait and set paginating to false when the component updates }); }