From 366a24bbe43d5624d04ad7fa98df7e94256cf54b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 22 Jan 2016 15:11:36 +0000 Subject: [PATCH 1/4] Refresh the membership list on 3PID invites --- src/components/views/rooms/MemberList.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 3af4cdc44f..de6911b2bd 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -51,6 +51,7 @@ module.exports = React.createClass({ var cli = MatrixClientPeg.get(); cli.on("RoomState.members", this.onRoomStateMember); cli.on("RoomMember.name", this.onRoomMemberName); + cli.on("RoomState.events", this.onRoomStateEvent); cli.on("Room", this.onRoom); // invites }, @@ -60,6 +61,7 @@ module.exports = React.createClass({ MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember); MatrixClientPeg.get().removeListener("RoomMember.name", this.onRoomMemberName); MatrixClientPeg.get().removeListener("User.presence", this.userPresenceFn); + MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvent); } }, @@ -133,6 +135,12 @@ module.exports = React.createClass({ this._updateList(); }, + onRoomStateEvent: function(event, state) { + if (event.getType() === "m.room.third_party_invite") { + this._updateList(); + } + }, + _updateList: function() { this.memberDict = this.getMemberDict(); From ec54c7cf6c9f23403eb57ab5a3db1bec5915380f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 22 Jan 2016 15:21:41 +0000 Subject: [PATCH 2/4] Match entities based on uid/displayname and include partials/stripping "foo" would now match: - @foobar:matrix.org - User ID matching - Foobar - Display name matching - f (@foo2:matrix.org) - user ID localpart matching - Bar Foo - Word matching --- src/Entities.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Entities.js b/src/Entities.js index 47103bfb65..a803d0c71a 100644 --- a/src/Entities.js +++ b/src/Entities.js @@ -17,6 +17,31 @@ limitations under the License. var React = require('react'); var sdk = require('./index'); +function isMatch(query, name, uid) { + query = query.toLowerCase(); + name = name.toLowerCase(); + uid = uid.toLowerCase(); + + // direct prefix matches + if (name.indexOf(query) === 0 || uid.indexOf(query) === 0) { + return true; + } + + // strip @ on uid and try matching again + if (uid.length > 1 && uid.substring(1).indexOf(query) === 0) { + return true; + } + + // split spaces in name and try matching constituient parts + var parts = name.split(" "); + for (var i = 0; i < parts.length; i++) { + if (parts[i].indexOf(query) === 0) { + return true; + } + } + return false; +} + /* * Converts various data models to Entity objects. * @@ -49,7 +74,7 @@ class MemberEntity extends Entity { } matches(queryString) { - return this.model.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0; + return isMatch(queryString, this.model.name, this.model.userId); } } @@ -77,7 +102,7 @@ class UserEntity extends Entity { matches(queryString) { var name = this.model.displayName || this.model.userId; - return name.toLowerCase().indexOf(queryString.toLowerCase()) === 0; + return isMatch(queryString, name, this.model.userId); } } From 99da0ef656131d38668fc59b611b5d01693df971 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 22 Jan 2016 16:11:09 +0000 Subject: [PATCH 3/4] Fix vector-im/vector-web#694 - Empty invitee list The invitee list is lazy-loaded 50ms after the first render. We were relying on setState from the member lazy-load to also kick the invitee list. However, setState is synchronous and we were loading the invitee list afterwards, which meant that the SearchableEntityList wouldn't have any invitees until the next render(). --- src/components/views/rooms/MemberList.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 3af4cdc44f..16ecad8885 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -69,11 +69,13 @@ module.exports = React.createClass({ // Lazy-load in more than the first N members setTimeout(function() { if (!self.isMounted()) return; + // lazy load to prevent it blocking the first render + self._loadUserList(); + self.setState({ members: self.roomMembers() }); - // lazy load to prevent it blocking the first render - self._loadUserList(); + }, 50); // Attach a SINGLE listener for global presence changes then locate the From 2d96f901815e64c75135736b3c0ead90e4416ebc Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 22 Jan 2016 16:18:23 +0000 Subject: [PATCH 4/4] Review comments --- src/Entities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entities.js b/src/Entities.js index a803d0c71a..5a666b1493 100644 --- a/src/Entities.js +++ b/src/Entities.js @@ -28,11 +28,11 @@ function isMatch(query, name, uid) { } // strip @ on uid and try matching again - if (uid.length > 1 && uid.substring(1).indexOf(query) === 0) { + if (uid.length > 1 && uid[0] === "@" && uid.substring(1).indexOf(query) === 0) { return true; } - // split spaces in name and try matching constituient parts + // split spaces in name and try matching constituent parts var parts = name.split(" "); for (var i = 0; i < parts.length; i++) { if (parts[i].indexOf(query) === 0) {