mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-24 00:38:31 +08:00
Disable link and button while leaving
This commit is contained in:
parent
09af614fb8
commit
b1b226d79b
@ -64,3 +64,8 @@ Please see LICENSE in the repository root for full details.
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
@ -9,10 +9,11 @@ import { Link } from "react-router-dom";
|
|||||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import { FC, useCallback, MouseEvent } from "react";
|
import { FC, useCallback, MouseEvent, useState } from "react";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { IconButton } from "@vector-im/compound-web";
|
import { IconButton } from "@vector-im/compound-web";
|
||||||
import { CloseIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
import { CloseIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
import { Avatar, Size } from "../Avatar";
|
import { Avatar, Size } from "../Avatar";
|
||||||
import styles from "./CallList.module.css";
|
import styles from "./CallList.module.css";
|
||||||
@ -60,30 +61,50 @@ interface CallTileProps {
|
|||||||
|
|
||||||
const CallTile: FC<CallTileProps> = ({ name, avatarUrl, room, client }) => {
|
const CallTile: FC<CallTileProps> = ({ name, avatarUrl, room, client }) => {
|
||||||
const roomEncryptionSystem = useRoomEncryptionSystem(room.roomId);
|
const roomEncryptionSystem = useRoomEncryptionSystem(room.roomId);
|
||||||
|
const [isLeaving, setIsLeaving] = useState(false);
|
||||||
|
|
||||||
const onRemove = useCallback(
|
const onRemove = useCallback(
|
||||||
(e: MouseEvent) => {
|
(e: MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
void client.leave(room.roomId);
|
setIsLeaving(true);
|
||||||
|
client.leave(room.roomId).catch(() => setIsLeaving(false));
|
||||||
},
|
},
|
||||||
[room, client],
|
[room, client],
|
||||||
);
|
);
|
||||||
return (
|
|
||||||
<div className={styles.callTile}>
|
const body = (
|
||||||
<Link
|
<>
|
||||||
to={getRelativeRoomUrl(room.roomId, roomEncryptionSystem, room.name)}
|
|
||||||
className={styles.callTileLink}
|
|
||||||
>
|
|
||||||
<Avatar id={room.roomId} name={name} size={Size.LG} src={avatarUrl} />
|
<Avatar id={room.roomId} name={name} size={Size.LG} src={avatarUrl} />
|
||||||
<div className={styles.callInfo}>
|
<div className={styles.callInfo}>
|
||||||
<Body overflowEllipsis fontWeight="semiBold">
|
<Body overflowEllipsis fontWeight="semiBold">
|
||||||
{name}
|
{name}
|
||||||
</Body>
|
</Body>
|
||||||
</div>
|
</div>
|
||||||
<IconButton onClick={onRemove} aria-label={t("action.remove")}>
|
<IconButton
|
||||||
|
onClick={onRemove}
|
||||||
|
disabled={isLeaving}
|
||||||
|
aria-label={t("action.remove")}
|
||||||
|
>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.callTile}>
|
||||||
|
{isLeaving ? (
|
||||||
|
<span className={classNames(styles.callTileLink, styles.disabled)}>
|
||||||
|
{body}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
to={getRelativeRoomUrl(room.roomId, roomEncryptionSystem, room.name)}
|
||||||
|
className={styles.callTileLink}
|
||||||
|
>
|
||||||
|
{body}
|
||||||
</Link>
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user