Files
element-call/src/home/CallList.tsx
T

77 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-05-04 17:09:48 +01:00
/*
Copyright 2022-2024 New Vector Ltd.
2022-05-04 17:09:48 +01:00
SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
2022-05-04 17:09:48 +01:00
*/
2021-12-07 17:59:55 -08:00
import { Link } from "react-router-dom";
2022-08-12 16:46:53 -04:00
import { MatrixClient } from "matrix-js-sdk/src/client";
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
2023-09-19 22:04:37 +01:00
import { Room } from "matrix-js-sdk/src/models/room";
2023-09-22 18:05:13 -04:00
import { FC } from "react";
2022-07-14 19:20:52 +02:00
import { Avatar, Size } from "../Avatar";
2021-12-09 12:58:30 -08:00
import styles from "./CallList.module.css";
import { getRelativeRoomUrl } from "../utils/matrix";
2023-08-11 13:25:09 +02:00
import { Body } from "../typography/Typography";
2022-07-14 19:20:52 +02:00
import { GroupCallRoom } from "./useGroupCallRooms";
2024-04-23 15:15:13 +02:00
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
2021-12-07 17:59:55 -08:00
2022-07-14 19:20:52 +02:00
interface CallListProps {
rooms: GroupCallRoom[];
client: MatrixClient;
}
2023-09-22 18:05:13 -04:00
export const CallList: FC<CallListProps> = ({ rooms, client }) => {
2021-12-09 12:58:30 -08:00
return (
<>
<div className={styles.callList}>
2023-09-19 17:42:17 +01:00
{rooms.map(({ room, roomName, avatarUrl, participants }) => (
2021-12-09 12:58:30 -08:00
<CallTile
key={room.roomId}
2021-12-20 09:12:28 -08:00
client={client}
2021-12-09 12:58:30 -08:00
name={roomName}
avatarUrl={avatarUrl}
2023-09-19 18:23:44 +01:00
room={room}
2021-12-09 12:58:30 -08:00
participants={participants}
/>
))}
2022-01-05 16:12:58 -08:00
{rooms.length > 3 && (
<>
<div className={styles.callTileSpacer} />
<div className={styles.callTileSpacer} />
</>
)}
2021-12-09 12:58:30 -08:00
</div>
</>
);
2023-09-22 18:05:13 -04:00
};
2022-07-14 19:20:52 +02:00
interface CallTileProps {
name: string;
avatarUrl: string;
2023-09-19 18:23:44 +01:00
room: Room;
2022-07-14 19:20:52 +02:00
participants: RoomMember[];
client: MatrixClient;
}
2023-09-22 18:05:13 -04:00
const CallTile: FC<CallTileProps> = ({ name, avatarUrl, room }) => {
2024-04-23 15:15:13 +02:00
const roomEncryptionSystem = useRoomEncryptionSystem(room.roomId);
2021-12-07 17:59:55 -08:00
return (
2021-12-10 14:01:55 -08:00
<div className={styles.callTile}>
2023-09-19 18:23:44 +01:00
<Link
2024-04-23 15:15:13 +02:00
to={getRelativeRoomUrl(room.roomId, roomEncryptionSystem, room.name)}
2023-09-19 18:23:44 +01:00
className={styles.callTileLink}
>
<Avatar id={room.roomId} name={name} size={Size.LG} src={avatarUrl} />
2021-12-10 14:01:55 -08:00
<div className={styles.callInfo}>
2022-01-04 17:09:27 -08:00
<Body overflowEllipsis fontWeight="semiBold">
{name}
</Body>
2021-12-10 14:01:55 -08:00
</div>
<div className={styles.copyButtonSpacer} />
</Link>
</div>
2021-12-07 17:59:55 -08:00
);
2023-09-22 18:05:13 -04:00
};