From 2271ec7634aefe0df8196de4eb356a1872b33281 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 2 Mar 2016 14:24:00 +0000 Subject: [PATCH 1/2] Display room metadata from room previews when we come from the public room directory (more hacks to work around the fact that we can't get this data from the HS) --- src/components/structures/RoomDirectory.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 6cc90f7968..3fecd3f68e 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -66,9 +66,27 @@ module.exports = React.createClass({ }, showRoom: function(roomId) { + var room; + for (var i = 0; i < this.state.publicRooms.length; ++i) { + if (this.state.publicRooms[i].room_id == roomId) { + room = this.state.publicRooms[i]; + break; + } + } + var oob_data = {}; + if (room) { + oob_data = { + 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], + }; + } + dis.dispatch({ action: 'view_room', - room_id: roomId + room_id: roomId, + oob_data: oob_data, }); }, From b03e6a8d73dda39871e2cd372202a534852b02a3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 2 Mar 2016 14:34:31 +0000 Subject: [PATCH 2/2] add comment explaining data passing hack --- src/components/structures/RoomDirectory.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 3fecd3f68e..f0b20e3f9b 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -66,6 +66,10 @@ module.exports = React.createClass({ }, showRoom: function(roomId) { + // extract the metadata from the publicRooms structure to pass + // as out-of-band data to view_room, because we get information + // here that we can't get other than by joining the room in some + // cases. var room; for (var i = 0; i < this.state.publicRooms.length; ++i) { if (this.state.publicRooms[i].room_id == roomId) {