Skip to content

Commit adb6ab3

Browse files
committed
Merge pull request element-hq#1069 from vector-im/dbkr/directory_room_metadata
Display room metadata from room previews when we come from the public room directory
2 parents 332354e + b03e6a8 commit adb6ab3

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/components/structures/RoomDirectory.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,31 @@ module.exports = React.createClass({
6666
},
6767

6868
showRoom: function(roomId) {
69+
// extract the metadata from the publicRooms structure to pass
70+
// as out-of-band data to view_room, because we get information
71+
// here that we can't get other than by joining the room in some
72+
// cases.
73+
var room;
74+
for (var i = 0; i < this.state.publicRooms.length; ++i) {
75+
if (this.state.publicRooms[i].room_id == roomId) {
76+
room = this.state.publicRooms[i];
77+
break;
78+
}
79+
}
80+
var oob_data = {};
81+
if (room) {
82+
oob_data = {
83+
avatarUrl: room.avatar_url,
84+
// XXX: This logic is duplicated from the JS SDK which
85+
// would normally decide what the name is.
86+
name: room.name || room.aliases[0],
87+
};
88+
}
89+
6990
dis.dispatch({
7091
action: 'view_room',
71-
room_id: roomId
92+
room_id: roomId,
93+
oob_data: oob_data,
7294
});
7395
},
7496

0 commit comments

Comments
 (0)