Display the list of spaces
This commit is contained in:
32
matrixgw_frontend/src/widgets/messages/RoomIcon.tsx
Normal file
32
matrixgw_frontend/src/widgets/messages/RoomIcon.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Icon } from "@mui/material";
|
||||
import { MatrixApiMedia } from "../../api/matrix/MatrixApiMedia";
|
||||
import type { UsersMap } from "../../api/matrix/MatrixApiProfile";
|
||||
import type { Room } from "../../api/matrix/MatrixApiRoom";
|
||||
import { useUserInfo } from "../dashboard/BaseAuthenticatedPage";
|
||||
import GroupIcon from "@mui/icons-material/Group";
|
||||
|
||||
export function RoomIcon(p: {
|
||||
room: Room;
|
||||
users: UsersMap;
|
||||
}): React.ReactElement {
|
||||
const user = useUserInfo();
|
||||
|
||||
let url = p.room.avatar;
|
||||
|
||||
if (!url && p.room.members.length <= 1) url = p.room.members[0];
|
||||
|
||||
if (!url && p.room.members.length < 2)
|
||||
url =
|
||||
p.room.members[0] == user.info.matrix_user_id
|
||||
? p.room.members[1]
|
||||
: p.room.members[0];
|
||||
|
||||
if (!url) return <GroupIcon />;
|
||||
else
|
||||
return (
|
||||
<img
|
||||
src={MatrixApiMedia.MediaURL(url, true)}
|
||||
style={{ maxWidth: "1em", maxHeight: "1em" }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user