2022-05-04 16:09:48 +00:00
|
|
|
/*
|
|
|
|
Copyright 2022 Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-01-05 01:09:27 +00:00
|
|
|
import React from "react";
|
2021-12-08 01:59:55 +00:00
|
|
|
import { Link } from "react-router-dom";
|
2022-01-05 01:09:27 +00:00
|
|
|
import { CopyButton } from "../button";
|
|
|
|
import { Facepile } from "../Facepile";
|
|
|
|
import { Avatar } from "../Avatar";
|
2021-12-09 20:58:30 +00:00
|
|
|
import styles from "./CallList.module.css";
|
2022-01-06 01:19:03 +00:00
|
|
|
import { getRoomUrl } from "../matrix-utils";
|
2022-01-05 01:09:27 +00:00
|
|
|
import { Body, Caption } from "../typography/Typography";
|
2021-12-08 01:59:55 +00:00
|
|
|
|
2022-01-21 19:10:12 +00:00
|
|
|
export function CallList({ rooms, client, disableFacepile }) {
|
2021-12-09 20:58:30 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className={styles.callList}>
|
2021-12-10 21:44:06 +00:00
|
|
|
{rooms.map(({ roomId, roomName, avatarUrl, participants }) => (
|
2021-12-09 20:58:30 +00:00
|
|
|
<CallTile
|
|
|
|
key={roomId}
|
2021-12-20 17:12:28 +00:00
|
|
|
client={client}
|
2021-12-09 20:58:30 +00:00
|
|
|
name={roomName}
|
|
|
|
avatarUrl={avatarUrl}
|
2021-12-10 21:44:06 +00:00
|
|
|
roomId={roomId}
|
2021-12-09 20:58:30 +00:00
|
|
|
participants={participants}
|
2022-01-21 19:10:12 +00:00
|
|
|
disableFacepile={disableFacepile}
|
2021-12-09 20:58:30 +00:00
|
|
|
/>
|
|
|
|
))}
|
2022-01-06 00:12:58 +00:00
|
|
|
{rooms.length > 3 && (
|
|
|
|
<>
|
|
|
|
<div className={styles.callTileSpacer} />
|
|
|
|
<div className={styles.callTileSpacer} />
|
|
|
|
</>
|
|
|
|
)}
|
2021-12-09 20:58:30 +00:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-21 19:10:12 +00:00
|
|
|
function CallTile({
|
|
|
|
name,
|
|
|
|
avatarUrl,
|
|
|
|
roomId,
|
|
|
|
participants,
|
|
|
|
client,
|
|
|
|
disableFacepile,
|
|
|
|
}) {
|
2021-12-08 01:59:55 +00:00
|
|
|
return (
|
2021-12-10 22:01:55 +00:00
|
|
|
<div className={styles.callTile}>
|
|
|
|
<Link to={`/room/${roomId}`} className={styles.callTileLink}>
|
|
|
|
<Avatar
|
2022-01-05 01:09:27 +00:00
|
|
|
size="lg"
|
2021-12-10 22:01:55 +00:00
|
|
|
bgKey={name}
|
|
|
|
src={avatarUrl}
|
2022-01-22 00:41:00 +00:00
|
|
|
fallback={name.slice(0, 1).toUpperCase()}
|
2021-12-10 22:01:55 +00:00
|
|
|
className={styles.avatar}
|
|
|
|
/>
|
|
|
|
<div className={styles.callInfo}>
|
2022-01-05 01:09:27 +00:00
|
|
|
<Body overflowEllipsis fontWeight="semiBold">
|
|
|
|
{name}
|
|
|
|
</Body>
|
|
|
|
<Caption overflowEllipsis>{getRoomUrl(roomId)}</Caption>
|
2022-01-21 19:10:12 +00:00
|
|
|
{participants && !disableFacepile && (
|
2022-01-05 01:09:27 +00:00
|
|
|
<Facepile
|
|
|
|
className={styles.facePile}
|
|
|
|
client={client}
|
|
|
|
participants={participants}
|
|
|
|
/>
|
2021-12-20 17:12:28 +00:00
|
|
|
)}
|
2021-12-10 22:01:55 +00:00
|
|
|
</div>
|
|
|
|
<div className={styles.copyButtonSpacer} />
|
|
|
|
</Link>
|
2021-12-08 01:59:55 +00:00
|
|
|
<CopyButton
|
|
|
|
className={styles.copyButton}
|
|
|
|
variant="icon"
|
2021-12-10 21:44:06 +00:00
|
|
|
value={getRoomUrl(roomId)}
|
2021-12-08 01:59:55 +00:00
|
|
|
/>
|
2021-12-10 22:01:55 +00:00
|
|
|
</div>
|
2021-12-08 01:59:55 +00:00
|
|
|
);
|
|
|
|
}
|