Skip to content

Commit c843ee3

Browse files
committed
handle canonical aliases correctly; search on names; support rooms with no aliases
1 parent 490cbbd commit c843ee3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/components/structures/RoomDirectory.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = React.createClass({
8383
avatarUrl: room.avatar_url,
8484
// XXX: This logic is duplicated from the JS SDK which
8585
// would normally decide what the name is.
86-
name: room.name || room.aliases[0],
86+
name: room.name || room.canonical_alias || room.aliases[0],
8787
};
8888
}
8989

@@ -102,15 +102,18 @@ module.exports = React.createClass({
102102
var rooms = this.state.publicRooms.filter(function(a) {
103103
// FIXME: if incrementally typing, keep narrowing down the search set
104104
// incrementally rather than starting over each time.
105-
return (a.aliases[0].toLowerCase().search(filter.toLowerCase()) >= 0 && a.num_joined_members > 0);
105+
return (((a.name && a.name.toLowerCase().search(filter.toLowerCase()) >= 0) ||
106+
(a.aliases && a.aliases[0].toLowerCase().search(filter.toLowerCase()) >= 0)) &&
107+
a.num_joined_members > 0);
106108
}).sort(function(a,b) {
107109
return a.num_joined_members - b.num_joined_members;
108110
});
109111
var rows = [];
110112
var self = this;
111113
var guestRead, guestJoin, perms;
112114
for (var i = 0; i < rooms.length; i++) {
113-
var name = rooms[i].name || rooms[i].aliases[0];
115+
var alias = rooms[i].canonical_alias || rooms[i].aliases[0];
116+
var name = rooms[i].name || alias;
114117
guestRead = null;
115118
guestJoin = null;
116119

@@ -148,7 +151,7 @@ module.exports = React.createClass({
148151
<div className="mx_RoomDirectory_topic"
149152
onClick={ function(e) { e.stopPropagation() } }
150153
dangerouslySetInnerHTML={{ __html: topic }}/>
151-
<div className="mx_RoomDirectory_alias">{ rooms[i].aliases[0] }</div>
154+
<div className="mx_RoomDirectory_alias">{ alias }</div>
152155
</td>
153156
<td className="mx_RoomDirectory_roomMemberCount">
154157
{ rooms[i].num_joined_members }

0 commit comments

Comments
 (0)