From 86cbe34181c3705953e83dcfe3e67a49bce836e5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 14 Sep 2018 18:35:16 +0200 Subject: [PATCH 01/14] rerender after members are loaded so pills and RR get rerendered --- src/components/structures/RoomView.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 3a2a80f06a..2715a5698d 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -585,18 +585,23 @@ module.exports = React.createClass({ this._loadMembersIfJoined(); }, - _loadMembersIfJoined: function() { + _loadMembersIfJoined: async function() { // lazy load members if enabled if (SettingsStore.isFeatureEnabled('feature_lazyloading')) { const cli = MatrixClientPeg.get(); const room = cli.getRoom(this.state.roomId); if (room && room.getMyMembership() === 'join') { - room.loadMembersIfNeeded().catch((err) => { + try { + await room.loadMembersIfNeeded(); + if (!this.unmounted) { + this.forceUpdate(); + } + } catch(err) { const errorMessage = `Fetching room members for ${room.roomId} failed.` + " Room members will appear incomplete."; console.error(errorMessage); console.error(err); - }); + } } } }, From 2ed414494f24435e459e5da0b2ff64e46b0bd254 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:14:52 +0200 Subject: [PATCH 02/14] use Room.myMembership event instead of RoomMember.membership for me This is more reliable with LL enabled as the syncing user is only known when it was active in the current timeline or when the members have been loaded --- src/actions/MatrixActionCreators.js | 11 ++++------- src/components/structures/RoomView.js | 10 +++++----- src/components/views/rooms/MemberList.js | 17 ++++++++--------- src/stores/RoomListStore.js | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/actions/MatrixActionCreators.js b/src/actions/MatrixActionCreators.js index 17be9a5e0f..a18dc77551 100644 --- a/src/actions/MatrixActionCreators.js +++ b/src/actions/MatrixActionCreators.js @@ -149,7 +149,7 @@ function createRoomTimelineAction(matrixClient, timelineEvent, room, toStartOfTi */ /** - * Create a MatrixActions.Room.selfMembership action that represents + * Create a MatrixActions.Room.myMembership action that represents * a MatrixClient `RoomMember.membership` matrix event for the syncing user, * emitted when the member's membership is updated. * @@ -159,11 +159,8 @@ function createRoomTimelineAction(matrixClient, timelineEvent, room, toStartOfTi * @param {string} oldMembership the member's previous membership. * @returns {RoomMembershipAction} an action of type `MatrixActions.RoomMember.membership`. */ -function createSelfRoomMembershipAction(matrixClient, membershipEvent, member, oldMembership) { - if (member.userId === matrixClient.getUserId()) { - return { action: 'MatrixActions.Room.selfMembership', member }; - } - return null; +function createSelfMembershipAction(matrixClient, room, membership, oldMembership) { + return { action: 'MatrixActions.Room.myMembership', room, membership, oldMembership}; } /** @@ -205,7 +202,7 @@ export default { this._addMatrixClientListener(matrixClient, 'Room', createRoomAction); this._addMatrixClientListener(matrixClient, 'Room.tags', createRoomTagsAction); this._addMatrixClientListener(matrixClient, 'Room.timeline', createRoomTimelineAction); - this._addMatrixClientListener(matrixClient, 'RoomMember.membership', createSelfRoomMembershipAction); + this._addMatrixClientListener(matrixClient, 'Room.myMembership', createSelfMembershipAction); this._addMatrixClientListener(matrixClient, 'Event.decrypted', createEventDecryptedAction); }, diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 2715a5698d..cf99bb9fc3 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -148,7 +148,7 @@ module.exports = React.createClass({ MatrixClientPeg.get().on("Room.name", this.onRoomName); MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData); MatrixClientPeg.get().on("RoomState.members", this.onRoomStateMember); - MatrixClientPeg.get().on("RoomMember.membership", this.onRoomMemberMembership); + MatrixClientPeg.get().on("Room.myMembership", this.onMyMembership); MatrixClientPeg.get().on("accountData", this.onAccountData); // Start listening for RoomViewStore updates @@ -412,8 +412,8 @@ module.exports = React.createClass({ MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline); MatrixClientPeg.get().removeListener("Room.name", this.onRoomName); MatrixClientPeg.get().removeListener("Room.accountData", this.onRoomAccountData); + MatrixClientPeg.get().removeListener("Room.myMembership", this.onMyMembership); MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember); - MatrixClientPeg.get().removeListener("RoomMember.membership", this.onRoomMemberMembership); MatrixClientPeg.get().removeListener("accountData", this.onAccountData); } @@ -715,10 +715,10 @@ module.exports = React.createClass({ this._updateRoomMembers(); }, - onRoomMemberMembership: function(ev, member, oldMembership) { - if (member.userId == MatrixClientPeg.get().credentials.userId) { - this._loadMembersIfJoined(); + onMyMembership: function(room, membership, oldMembership) { + if (room.roomId === this.state.roomId) { this.forceUpdate(); + this._loadMembersIfJoined(room); } }, diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 6a00c88d37..854bd20c30 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -43,11 +43,14 @@ module.exports = React.createClass({ componentWillMount: function() { this._mounted = false; const cli = MatrixClientPeg.get(); - if (!cli.hasLazyLoadMembersEnabled()) { + if (cli.hasLazyLoadMembersEnabled()) { + // true means will not show a spinner but the + // known members so far if not joined + cli.on("Room.myMembership", this.onMyMembership); + } else { this._listenForMembersChanges(); } cli.on("Room", this.onRoom); // invites & joining after peek - cli.on("RoomMember.membership", this.onRoomMembership); // update when accepting an invite const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"]; const hsUrl = MatrixClientPeg.get().baseUrl; this._showPresence = true; @@ -79,7 +82,7 @@ module.exports = React.createClass({ if (cli) { cli.removeListener("RoomState.members", this.onRoomStateMember); cli.removeListener("RoomMember.name", this.onRoomMemberName); - cli.removeListener("RoomMember.membership", this.onRoomMembership); + cli.removeListener("Room.myMembership", this.onMyMembership); cli.removeListener("RoomState.events", this.onRoomStateEvent); cli.removeListener("Room", this.onRoom); cli.removeListener("User.lastPresenceTs", this.onUserLastPresenceTs); @@ -182,12 +185,8 @@ module.exports = React.createClass({ this._loadMembersIfNeeded(); }, - onRoomMembership: function(ev, member, oldMembership) { - const cli = MatrixClientPeg.get(); - const myId = cli.getUserId(); - if (member.userId === myId && oldMembership !== "join" && member.membership === "join") { - // once we've joined, no need to listen for membership anymore - cli.removeListener("RoomMember.membership", this.onRoomMembership); + onMyMembership: function(room, membership, oldMembership) { + if (room.roomId === this.props.roomId && membership === "join") { this._loadMembersIfNeeded(); } }, diff --git a/src/stores/RoomListStore.js b/src/stores/RoomListStore.js index 5a041f52ac..67c0c13be7 100644 --- a/src/stores/RoomListStore.js +++ b/src/stores/RoomListStore.js @@ -120,7 +120,7 @@ class RoomListStore extends Store { this._generateRoomLists(); } break; - case 'MatrixActions.Room.selfMembership': { + case 'MatrixActions.Room.myMembership': { this._generateRoomLists(); } break; From c3914d34931877a38433802c5bb73007d2cc146a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:18:55 +0200 Subject: [PATCH 03/14] show empty list as initial state instead of spinner the spinner should only be shown when joined --- src/components/views/rooms/MemberList.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 854bd20c30..3a2dba9054 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -34,9 +34,10 @@ module.exports = React.createClass({ getInitialState: function() { const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { - return {loading: true}; + // show an empty list + return this._getMembersState([]); } else { - return this._getMembersState(); + return this._getMembersState(this.roomMembers()); } }, @@ -46,6 +47,7 @@ module.exports = React.createClass({ if (cli.hasLazyLoadMembersEnabled()) { // true means will not show a spinner but the // known members so far if not joined + this._loadMembersIfNeeded(true); cli.on("Room.myMembership", this.onMyMembership); } else { this._listenForMembersChanges(); @@ -73,7 +75,6 @@ module.exports = React.createClass({ componentDidMount: async function() { this._mounted = true; - this._loadMembersIfNeeded(true); }, componentWillUnmount: function() { @@ -104,18 +105,17 @@ module.exports = React.createClass({ await room.loadMembersIfNeeded(); } catch(ex) {/* already logged in RoomView */} if (this._mounted) { - this.setState(this._getMembersState()); + this.setState(this._getMembersState(this.roomMembers())); this._listenForMembersChanges(); } } else if(initial) { // show the members we've got - this.setState(this._getMembersState()); + this.setState(this._getMembersState(this.roomMembers())); } } }, - _getMembersState: function() { - const members = this.roomMembers(); + _getMembersState: function(members) { // set the state after determining _showPresence to make sure it's // taken into account while rerendering return { From d276b17c2afa70b72ebbef6446fc74668217f9d0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:19:07 +0200 Subject: [PATCH 04/14] remove dead code --- src/components/views/rooms/MemberList.js | 29 ------------------------ 1 file changed, 29 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 3a2dba9054..2d3bc69ced 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -87,7 +87,6 @@ module.exports = React.createClass({ cli.removeListener("RoomState.events", this.onRoomStateEvent); cli.removeListener("Room", this.onRoom); cli.removeListener("User.lastPresenceTs", this.onUserLastPresenceTs); - // cli.removeListener("Room.timeline", this.onRoomTimeline); } // cancel any pending calls to the rate_limited_funcs @@ -132,34 +131,6 @@ module.exports = React.createClass({ }; }, -/* - onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) { - // ignore anything but real-time updates at the end of the room: - // updates from pagination will happen when the paginate completes. - if (toStartOfTimeline || !data || !data.liveEvent) return; - - // treat any activity from a user as implicit presence to update the - // ordering of the list whenever someone says something. - // Except right now we're not tiebreaking "active now" users in this way - // so don't bother for now. - if (ev.getSender()) { - // console.log("implicit presence from " + ev.getSender()); - - var tile = this.refs[ev.getSender()]; - if (tile) { - // work around a race where you might have a room member object - // before the user object exists. XXX: why does this ever happen? - var all_members = room.currentState.members; - var userId = ev.getSender(); - if (all_members[userId].user === null) { - all_members[userId].user = MatrixClientPeg.get().getUser(userId); - } - this._updateList(); // reorder the membership list - } - } - }, -*/ - onUserLastPresenceTs(event, user) { // Attach a SINGLE listener for global presence changes then locate the // member tile and re-render it. This is more efficient than every tile From e1b9aa9626c26a157d26bb19315788ab8e2da4c0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:20:26 +0200 Subject: [PATCH 05/14] better naming and document method --- src/components/views/rooms/MemberList.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 2d3bc69ced..b7a64e0ec4 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -47,7 +47,7 @@ module.exports = React.createClass({ if (cli.hasLazyLoadMembersEnabled()) { // true means will not show a spinner but the // known members so far if not joined - this._loadMembersIfNeeded(true); + this._waitForMembersIfJoinedAndLL(true); cli.on("Room.myMembership", this.onMyMembership); } else { this._listenForMembersChanges(); @@ -93,7 +93,12 @@ module.exports = React.createClass({ this._updateList.cancelPendingCall(); }, - _loadMembersIfNeeded: async function(initial) { + /** + * If lazy loading is enabled, either: + * show a spinner and load the members if the user is joined, + * or show the members available so far if initial=true + */ + _waitForMembersIfJoinedAndLL: async function(initial) { const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { const cli = MatrixClientPeg.get(); @@ -153,12 +158,12 @@ module.exports = React.createClass({ // also when peeking, we need to await the members being loaded // before showing them. - this._loadMembersIfNeeded(); + this._waitForMembersIfJoinedAndLL(); }, onMyMembership: function(room, membership, oldMembership) { if (room.roomId === this.props.roomId && membership === "join") { - this._loadMembersIfNeeded(); + this._waitForMembersIfJoinedAndLL(); } }, From e0a789f77ede852be614ba1131afbab21f8e731a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:21:22 +0200 Subject: [PATCH 06/14] remove untrue comment, as we only load the members when joining --- src/components/views/rooms/MemberList.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index b7a64e0ec4..907f162a40 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -154,10 +154,6 @@ module.exports = React.createClass({ // We listen for room events because when we accept an invite // we need to wait till the room is fully populated with state // before refreshing the member list else we get a stale list. - - // also when peeking, we need to await the members being loaded - // before showing them. - this._waitForMembersIfJoinedAndLL(); }, From 473f2dd72b15255939b17a9cf8e45277ff373361 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:24:34 +0200 Subject: [PATCH 07/14] pass room to _loadMembersIfJoined, it's called when newState not applied _loadMembersIfJoined is called from _onRoomLoaded < _onRoomViewStoreUpdate, before incoming state from the store is applied to this.state, so looking up the room with this.state.roomId doesn't always work, which would cause the members not to be loaded. Pass in the room instead. --- src/components/structures/RoomView.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index cf99bb9fc3..8e2c2e3fdd 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -582,14 +582,13 @@ module.exports = React.createClass({ this._warnAboutEncryption(room); this._calculatePeekRules(room); this._updatePreviewUrlVisibility(room); - this._loadMembersIfJoined(); + this._loadMembersIfJoined(room); }, - _loadMembersIfJoined: async function() { + _loadMembersIfJoined: async function(room) { // lazy load members if enabled if (SettingsStore.isFeatureEnabled('feature_lazyloading')) { const cli = MatrixClientPeg.get(); - const room = cli.getRoom(this.state.roomId); if (room && room.getMyMembership() === 'join') { try { await room.loadMembersIfNeeded(); From 0ce7bb8995137eec9ca48820b029f08ec05fc7fd Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:27:25 +0200 Subject: [PATCH 08/14] pass membersLoaded state to TimelinePanel to force it to re-render ... once the members are loaded. --- src/components/structures/RoomView.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 8e2c2e3fdd..1a1dd4cf87 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -91,13 +91,16 @@ module.exports = React.createClass({ }, getInitialState: function() { + const llMembers = MatrixClientPeg.get().hasLazyLoadMembersEnabled(); return { room: null, roomId: null, roomLoading: true, peekLoading: false, shouldPeek: true, - + // used to trigger a rerender in TimelinePanel once the members are loaded, + // so RR are rendered again (now with the members available), ... + membersLoaded: !llMembers, // The event to be scrolled to initially initialEventId: null, // The offset in pixels from the event with which to scroll vertically @@ -593,7 +596,7 @@ module.exports = React.createClass({ try { await room.loadMembersIfNeeded(); if (!this.unmounted) { - this.forceUpdate(); + this.setState({membersLoaded: true}); } } catch(err) { const errorMessage = `Fetching room members for ${room.roomId} failed.` + @@ -1765,6 +1768,7 @@ module.exports = React.createClass({ onReadMarkerUpdated={this._updateTopUnreadMessagesBar} showUrlPreview = {this.state.showUrlPreview} className="mx_RoomView_messagePanel" + membersLoaded={this.state.membersLoaded} />); let topUnreadMessagesBar = null; From 841aa4b80089510b290bda79dffedcb86498d45d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 19:28:06 +0200 Subject: [PATCH 09/14] check LL with client as this takes server support into account --- src/components/structures/RoomView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 1a1dd4cf87..7996c0eab8 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -590,8 +590,8 @@ module.exports = React.createClass({ _loadMembersIfJoined: async function(room) { // lazy load members if enabled - if (SettingsStore.isFeatureEnabled('feature_lazyloading')) { - const cli = MatrixClientPeg.get(); + const cli = MatrixClientPeg.get(); + if (cli.hasLazyLoadMembersEnabled()) { if (room && room.getMyMembership() === 'join') { try { await room.loadMembersIfNeeded(); From e8b4770940f632f09e543b0bceaa211e08e5a06d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 20:01:55 +0200 Subject: [PATCH 10/14] fix lint --- src/components/structures/RoomView.js | 2 +- src/components/views/rooms/MemberList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 7996c0eab8..e9e46a2ff6 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -598,7 +598,7 @@ module.exports = React.createClass({ if (!this.unmounted) { this.setState({membersLoaded: true}); } - } catch(err) { + } catch (err) { const errorMessage = `Fetching room members for ${room.roomId} failed.` + " Room members will appear incomplete."; console.error(errorMessage); diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 907f162a40..f70347a449 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -107,7 +107,7 @@ module.exports = React.createClass({ this.setState({loading: true}); try { await room.loadMembersIfNeeded(); - } catch(ex) {/* already logged in RoomView */} + } catch (ex) {/* already logged in RoomView */} if (this._mounted) { this.setState(this._getMembersState(this.roomMembers())); this._listenForMembersChanges(); From 0727e0f8d3c0a6751c2092c2479682a54135f7d4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 20:02:15 +0200 Subject: [PATCH 11/14] mounted can be set straight in componentWillMount --- src/components/views/rooms/MemberList.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index f70347a449..8120ee5747 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -42,7 +42,7 @@ module.exports = React.createClass({ }, componentWillMount: function() { - this._mounted = false; + this._mounted = true; const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { // true means will not show a spinner but the @@ -73,10 +73,6 @@ module.exports = React.createClass({ // cli.on("Room.timeline", this.onRoomTimeline); }, - componentDidMount: async function() { - this._mounted = true; - }, - componentWillUnmount: function() { this._mounted = false; const cli = MatrixClientPeg.get(); From 8c4f4765df79e733c583164a7a31b88eb483a001 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 Sep 2018 20:03:01 +0200 Subject: [PATCH 12/14] remove initial parameter and show available members on invite instead --- src/components/views/rooms/MemberList.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 8120ee5747..67a6effc81 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -45,9 +45,7 @@ module.exports = React.createClass({ this._mounted = true; const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { - // true means will not show a spinner but the - // known members so far if not joined - this._waitForMembersIfJoinedAndLL(true); + this._showMembersAccordingToMembershipWithLL(); cli.on("Room.myMembership", this.onMyMembership); } else { this._listenForMembersChanges(); @@ -92,14 +90,15 @@ module.exports = React.createClass({ /** * If lazy loading is enabled, either: * show a spinner and load the members if the user is joined, - * or show the members available so far if initial=true + * or show the members available so far if the user is invited */ - _waitForMembersIfJoinedAndLL: async function(initial) { + _showMembersAccordingToMembershipWithLL: async function() { const cli = MatrixClientPeg.get(); if (cli.hasLazyLoadMembersEnabled()) { const cli = MatrixClientPeg.get(); const room = cli.getRoom(this.props.roomId); - if (room && room.getMyMembership() === 'join') { + const membership = room && room.getMyMembership(); + if (membership === "join") { this.setState({loading: true}); try { await room.loadMembersIfNeeded(); @@ -108,8 +107,8 @@ module.exports = React.createClass({ this.setState(this._getMembersState(this.roomMembers())); this._listenForMembersChanges(); } - } else if(initial) { - // show the members we've got + } else if (membership === "invite") { + // show the members we've got when invited this.setState(this._getMembersState(this.roomMembers())); } } @@ -150,12 +149,12 @@ module.exports = React.createClass({ // We listen for room events because when we accept an invite // we need to wait till the room is fully populated with state // before refreshing the member list else we get a stale list. - this._waitForMembersIfJoinedAndLL(); + this._showMembersAccordingToMembershipWithLL(); }, onMyMembership: function(room, membership, oldMembership) { if (room.roomId === this.props.roomId && membership === "join") { - this._waitForMembersIfJoinedAndLL(); + this._showMembersAccordingToMembershipWithLL(); } }, From e951a22d31bff725ac2319c85d32d6c44aec30ab Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Sep 2018 17:09:14 +0200 Subject: [PATCH 13/14] fix tests --- test/components/views/rooms/RoomList-test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/components/views/rooms/RoomList-test.js b/test/components/views/rooms/RoomList-test.js index fbb2dd4af9..e512b96ba8 100644 --- a/test/components/views/rooms/RoomList-test.js +++ b/test/components/views/rooms/RoomList-test.js @@ -74,6 +74,7 @@ describe('RoomList', () => { // Mock joined member myMember = new RoomMember(movingRoomId, myUserId); myMember.membership = 'join'; + movingRoom.updateMyMembership('join'); movingRoom.getMember = (userId) => ({ [client.credentials.userId]: myMember, }[userId]); @@ -81,6 +82,7 @@ describe('RoomList', () => { otherRoom = createRoom({name: 'Other room'}); myOtherMember = new RoomMember(otherRoom.roomId, myUserId); myOtherMember.membership = 'join'; + otherRoom.updateMyMembership('join'); otherRoom.getMember = (userId) => ({ [client.credentials.userId]: myOtherMember, }[userId]); From 93d34e7b3dcb007bca0598c98eb593b2abe5eec8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 19 Sep 2018 12:00:29 +0200 Subject: [PATCH 14/14] fix lint --- src/actions/MatrixActionCreators.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/actions/MatrixActionCreators.js b/src/actions/MatrixActionCreators.js index a18dc77551..31bcac3e52 100644 --- a/src/actions/MatrixActionCreators.js +++ b/src/actions/MatrixActionCreators.js @@ -144,23 +144,25 @@ function createRoomTimelineAction(matrixClient, timelineEvent, room, toStartOfTi /** * @typedef RoomMembershipAction * @type {Object} - * @property {string} action 'MatrixActions.RoomMember.membership'. - * @property {RoomMember} member the member whose membership was updated. + * @property {string} action 'MatrixActions.Room.myMembership'. + * @property {Room} room to room for which the self-membership changed. + * @property {string} membership the new membership + * @property {string} oldMembership the previous membership, can be null. */ /** * Create a MatrixActions.Room.myMembership action that represents - * a MatrixClient `RoomMember.membership` matrix event for the syncing user, - * emitted when the member's membership is updated. + * a MatrixClient `Room.myMembership` event for the syncing user, + * emitted when the syncing user's membership is updated for a room. * * @param {MatrixClient} matrixClient the matrix client. - * @param {MatrixEvent} membershipEvent the m.room.member event. - * @param {RoomMember} member the member whose membership was updated. - * @param {string} oldMembership the member's previous membership. - * @returns {RoomMembershipAction} an action of type `MatrixActions.RoomMember.membership`. + * @param {Room} room to room for which the self-membership changed. + * @param {string} membership the new membership + * @param {string} oldMembership the previous membership, can be null. + * @returns {RoomMembershipAction} an action of type `MatrixActions.Room.myMembership`. */ function createSelfMembershipAction(matrixClient, room, membership, oldMembership) { - return { action: 'MatrixActions.Room.myMembership', room, membership, oldMembership}; + return { action: 'MatrixActions.Room.myMembership', room, membership, oldMembership}; } /**