/* Copyright 2022-2024 New Vector Ltd. SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ import { Link } from "react-router-dom"; import { type RoomMember, type Room, type MatrixClient } from "matrix-js-sdk"; import { type FC, useCallback, type MouseEvent, useState } from "react"; import { useTranslation } from "react-i18next"; import { IconButton, Text } from "@vector-im/compound-web"; import { CloseIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; import classNames from "classnames"; import { Avatar, Size } from "../Avatar"; import styles from "./CallList.module.css"; import { getRelativeRoomUrl } from "../utils/matrix"; import { type GroupCallRoom } from "./useGroupCallRooms"; import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement"; interface CallListProps { rooms: GroupCallRoom[]; client: MatrixClient; } export const CallList: FC = ({ rooms, client }) => { return ( <>
{rooms.map(({ room, roomName, avatarUrl, participants }) => ( ))} {rooms.length > 3 && ( <>
)}
); }; interface CallTileProps { name: string; avatarUrl: string; room: Room; participants: RoomMember[]; client: MatrixClient; } const CallTile: FC = ({ name, avatarUrl, room, client }) => { const { t } = useTranslation(); const roomEncryptionSystem = useRoomEncryptionSystem(room.roomId); const [isLeaving, setIsLeaving] = useState(false); const onRemove = useCallback( (e: MouseEvent) => { e.stopPropagation(); e.preventDefault(); setIsLeaving(true); client.leave(room.roomId).catch(() => setIsLeaving(false)); }, [room, client], ); const body = ( <>
{name}
); return (
{isLeaving ? ( {body} ) : ( {body} )}
); };