From fee7ee5dcc1ab4ba90b689c1e87340e2b2d53395 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 20 Jan 2016 14:41:48 +0000 Subject: [PATCH] Load the user list eventually if we have no Room object --- src/components/views/rooms/MemberList.js | 26 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 9d20f5ab55..e38d6ae41d 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -71,14 +71,8 @@ module.exports = React.createClass({ self.setState({ members: self.roomMembers() }); - // Lazy-load the complete user list for inviting new users - // TODO: Keep this list bleeding-edge up-to-date. Practically speaking, - // it will do for now not being updated as random new users join different - // rooms as this list will be reloaded every room swap. - var room = MatrixClientPeg.get().getRoom(self.props.roomId); - self.userList = MatrixClientPeg.get().getUsers().filter(function(u) { - return !room.hasMembershipState(u.userId, "join"); - }); + // lazy load to prevent it blocking the first render + self._loadUserList(); }, 50); @@ -107,6 +101,21 @@ module.exports = React.createClass({ /*componentWillReceiveProps: function(newProps) { },*/ + _loadUserList: function() { + var room = MatrixClientPeg.get().getRoom(this.props.roomId); + if (!room) { + return; // we'll do it later + } + + // Load the complete user list for inviting new users + // TODO: Keep this list bleeding-edge up-to-date. Practically speaking, + // it will do for now not being updated as random new users join different + // rooms as this list will be reloaded every room swap. + this.userList = MatrixClientPeg.get().getUsers().filter(function(u) { + return !room.hasMembershipState(u.userId, "join"); + }); + }, + onRoom: function(room) { if (room.roomId !== this.props.roomId) { return; @@ -115,6 +124,7 @@ module.exports = React.createClass({ // we need to wait till the room is fully populated with state // before refreshing the member list else we get a stale list. this._updateList(); + this._loadUserList(); }, onRoomStateMember: function(ev, state, member) {