From c843ee3157451277c64cba7d6ecd45d9920f6d1f Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 23 Mar 2016 11:26:18 +0000 Subject: [PATCH] handle canonical aliases correctly; search on names; support rooms with no aliases --- src/components/structures/RoomDirectory.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 25489d74..de9d901c 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -83,7 +83,7 @@ module.exports = React.createClass({ avatarUrl: room.avatar_url, // XXX: This logic is duplicated from the JS SDK which // would normally decide what the name is. - name: room.name || room.aliases[0], + name: room.name || room.canonical_alias || room.aliases[0], }; } @@ -102,7 +102,9 @@ module.exports = React.createClass({ var rooms = this.state.publicRooms.filter(function(a) { // FIXME: if incrementally typing, keep narrowing down the search set // incrementally rather than starting over each time. - return (a.aliases[0].toLowerCase().search(filter.toLowerCase()) >= 0 && a.num_joined_members > 0); + return (((a.name && a.name.toLowerCase().search(filter.toLowerCase()) >= 0) || + (a.aliases && a.aliases[0].toLowerCase().search(filter.toLowerCase()) >= 0)) && + a.num_joined_members > 0); }).sort(function(a,b) { return a.num_joined_members - b.num_joined_members; }); @@ -110,7 +112,8 @@ module.exports = React.createClass({ var self = this; var guestRead, guestJoin, perms; for (var i = 0; i < rooms.length; i++) { - var name = rooms[i].name || rooms[i].aliases[0]; + var alias = rooms[i].canonical_alias || rooms[i].aliases[0]; + var name = rooms[i].name || alias; guestRead = null; guestJoin = null; @@ -148,7 +151,7 @@ module.exports = React.createClass({
-
{ rooms[i].aliases[0] }
+
{ alias }
{ rooms[i].num_joined_members }