From e4194460818ebca2b4c3b5350dc26137ee8856df Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 24 Oct 2017 10:13:38 +0100 Subject: [PATCH] Add fields needed by RoomDetailList to groupRoomFromApiObject and also alter props API for RDL to match the returned rooms. (This doesn't affect RoomDirectory - this does not use RDL (yet)) --- src/components/views/rooms/RoomDetailList.js | 38 +++++++++++++------- src/groups.js | 4 +++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/components/views/rooms/RoomDetailList.js b/src/components/views/rooms/RoomDetailList.js index 370bf1bb2d..be9de849e9 100644 --- a/src/components/views/rooms/RoomDetailList.js +++ b/src/components/views/rooms/RoomDetailList.js @@ -25,15 +25,28 @@ import MatrixClientPeg from '../../../MatrixClientPeg'; import PropTypes from 'prop-types'; function getDisplayAliasForRoom(room) { - return room.canonical_alias || (room.aliases ? room.aliases[0] : ""); + return room.canonicalAlias || (room.aliases ? room.aliases[0] : ""); } const RoomDetailRow = React.createClass({ + propTypes: PropTypes.shape({ + name: PropTypes.string, + topic: PropTypes.string, + roomId: PropTypes.string, + avatarUrl: PropTypes.string, + numJoinedMembers: PropTypes.number, + canonicalAlias: PropTypes.string, + aliases: PropTypes.arrayOf(PropTypes.string), + + worldReadable: PropTypes.bool, + guestCanJoin: PropTypes.bool, + }), + onClick: function(ev) { ev.preventDefault(); dis.dispatch({ action: 'view_room', - room_id: this.props.room.room_id, + room_id: this.props.room.roomId, }); }, @@ -50,10 +63,10 @@ const RoomDetailRow = React.createClass({ const name = room.name || getDisplayAliasForRoom(room) || _t('Unnamed room'); const topic = linkifyString(sanitizeHtml(room.topic || '')); - const guestRead = room.world_readable ? ( + const guestRead = room.worldReadable ? (
{ _t('World readable') }
) :
; - const guestJoin = room.guest_can_join ? ( + const guestJoin = room.guestCanJoin ? (
{ _t('Guests can join') }
) :
; @@ -62,13 +75,13 @@ const RoomDetailRow = React.createClass({ { guestJoin }
) :
; - return + return + room.avatarUrl, 24, 24, "crop")} />
{ name }
  @@ -79,7 +92,7 @@ const RoomDetailRow = React.createClass({
{ getDisplayAliasForRoom(room) }
- { room.num_joined_members } + { room.numJoinedMembers } ; }, @@ -92,13 +105,14 @@ export default React.createClass({ rooms: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string, topic: PropTypes.string, - room_id: PropTypes.string, - num_joined_members: PropTypes.number, - canonical_alias: PropTypes.string, + roomId: PropTypes.string, + avatarUrl: PropTypes.string, + numJoinedMembers: PropTypes.number, + canonicalAlias: PropTypes.string, aliases: PropTypes.arrayOf(PropTypes.string), - world_readable: PropTypes.bool, - guest_can_join: PropTypes.bool, + worldReadable: PropTypes.bool, + guestCanJoin: PropTypes.bool, })), }, diff --git a/src/groups.js b/src/groups.js index 69871c45e9..0679fce59e 100644 --- a/src/groups.js +++ b/src/groups.js @@ -43,5 +43,9 @@ export function groupRoomFromApiObject(apiObject) { roomId: apiObject.room_id, canonicalAlias: apiObject.canonical_alias, avatarUrl: apiObject.avatar_url, + topic: apiObject.topic, + numJoinedMembers: apiObject.num_joined_members, + worldReadable: apiObject.world_readable, + canGuestsJoin: apiObject.can_guests_join, }; }