From 229518e45682306eeef4a3f3af38d1f69fecf485 Mon Sep 17 00:00:00 2001 From: Manuel Stahl Date: Wed, 5 May 2021 20:24:15 +0200 Subject: [PATCH] Show room alias or room id in room list if room has no name Change-Id: Iad769f31347566ccf0b8a978b31f5123553e9dbc --- src/components/rooms.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/rooms.js b/src/components/rooms.js index a5d9ba2..47f309b 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -18,9 +18,11 @@ import { TabbedShowLayout, TextField, TopToolbar, + useRecordContext, useTranslate, } from "react-admin"; import get from "lodash/get"; +import PropTypes from "prop-types"; import { Tooltip, Typography, Chip } from "@material-ui/core"; import HttpsIcon from "@material-ui/icons/Https"; import NoEncryptionIcon from "@material-ui/icons/NoEncryption"; @@ -305,6 +307,20 @@ const RoomFilter = ({ ...props }) => { ); }; +const RoomNameField = props => { + const { source } = props; + const record = useRecordContext(props); + return ( + {record[source] || record["canonical_alias"] || record["id"]} + ); +}; + +RoomNameField.propTypes = { + label: PropTypes.string, + record: PropTypes.object, + source: PropTypes.string.isRequired, +}; + const FilterableRoomList = ({ roomFilters, dispatch, ...props }) => { const filter = roomFilters; const localMembersFilter = @@ -327,7 +343,7 @@ const FilterableRoomList = ({ roomFilters, dispatch, ...props }) => { sortBy="encryption" label={} /> - + {localMembersFilter && } {stateEventsFilter && }