From 7290a65924b830868ecb7c0bf712d2a1462514c3 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Sat, 14 Aug 2021 10:36:04 +0200 Subject: [PATCH] Migrate RoomDetailList to TypeScript --- .../{RoomDetailList.js => RoomDetailList.tsx} | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) rename src/components/views/rooms/{RoomDetailList.js => RoomDetailList.tsx} (81%) diff --git a/src/components/views/rooms/RoomDetailList.js b/src/components/views/rooms/RoomDetailList.tsx similarity index 81% rename from src/components/views/rooms/RoomDetailList.js rename to src/components/views/rooms/RoomDetailList.tsx index bf2f5418c9..ee7383d7c7 100644 --- a/src/components/views/rooms/RoomDetailList.js +++ b/src/components/views/rooms/RoomDetailList.tsx @@ -14,24 +14,23 @@ See the License for the specific language governing permissions and limitations under the License. */ +import React from 'react'; +import { Room } from 'matrix-js-sdk/src'; +import classNames from 'classnames'; import * as sdk from '../../../index'; import dis from '../../../dispatcher/dispatcher'; -import React from 'react'; import { _t } from '../../../languageHandler'; -import PropTypes from 'prop-types'; -import classNames from 'classnames'; -import { roomShape } from './RoomDetailRow'; import { replaceableComponent } from "../../../utils/replaceableComponent"; -@replaceableComponent("views.rooms.RoomDetailList") -export default class RoomDetailList extends React.Component { - static propTypes = { - rooms: PropTypes.arrayOf(roomShape), - className: PropTypes.string, - }; +interface IProps { + rooms?: Room[]; + className?: string; +} - getRows() { +@replaceableComponent("views.rooms.RoomDetailList") +export default class RoomDetailList extends React.Component { + public getRows(): JSX.Element[] { if (!this.props.rooms) return []; const RoomDetailRow = sdk.getComponent('rooms.RoomDetailRow'); @@ -40,15 +39,15 @@ export default class RoomDetailList extends React.Component { }); } - onDetailsClick = (ev, room) => { + public onDetailsClick = (ev: React.MouseEvent, room: Room): void => { dis.dispatch({ action: 'view_room', room_id: room.roomId, - room_alias: room.canonicalAlias || (room.aliases || [])[0], + room_alias: room.getCanonicalAlias() || (room.getAltAliases() || [])[0], }); }; - render() { + public render(): JSX.Element { const rows = this.getRows(); let rooms; if (rows.length === 0) {