mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-31 07:00:26 +00:00
lint
This commit is contained in:
@@ -15,18 +15,18 @@ configure({
|
||||
});
|
||||
|
||||
describe("RaisedHandIndicator", () => {
|
||||
test("renders nothing when no hand has been raised", async () => {
|
||||
test("renders nothing when no hand has been raised", () => {
|
||||
const { container } = render(<RaisedHandIndicator />);
|
||||
expect(container.firstChild).toBeNull();
|
||||
});
|
||||
test("renders an indicator when a hand has been raised", async () => {
|
||||
test("renders an indicator when a hand has been raised", () => {
|
||||
const dateTime = new Date();
|
||||
const { container } = render(
|
||||
<RaisedHandIndicator raisedHandTime={dateTime} />,
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
test("renders an indicator when a hand has been raised with the expected time", async () => {
|
||||
test("renders an indicator when a hand has been raised with the expected time", () => {
|
||||
const dateTime = new Date(new Date().getTime() - 60000);
|
||||
const { container } = render(
|
||||
<RaisedHandIndicator raisedHandTime={dateTime} />,
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
import { useEffect, useState } from "react";
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { ReactNode, useEffect, useState } from "react";
|
||||
|
||||
import styles from "./RaisedHandIndicator.module.css";
|
||||
|
||||
export function RaisedHandIndicator({
|
||||
raisedHandTime,
|
||||
}: {
|
||||
raisedHandTime?: Date;
|
||||
}) {
|
||||
}): ReactNode {
|
||||
const [raisedHandDuration, setRaisedHandDuration] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
if (!raisedHandTime) {
|
||||
return;
|
||||
}
|
||||
const calculateTime = () => {
|
||||
const calculateTime = (): void => {
|
||||
const totalSeconds = Math.ceil(
|
||||
(new Date().getTime() - raisedHandTime.getTime()) / 1000,
|
||||
);
|
||||
@@ -22,8 +30,8 @@ export function RaisedHandIndicator({
|
||||
`${minutes < 10 ? "0" : ""}${minutes}:${seconds < 10 ? "0" : ""}${seconds}`,
|
||||
);
|
||||
};
|
||||
const to = setInterval(calculateTime, 1000);
|
||||
calculateTime();
|
||||
const to = setInterval(calculateTime, 1000);
|
||||
return (): void => clearInterval(to);
|
||||
}, [setRaisedHandDuration, raisedHandTime]);
|
||||
|
||||
|
||||
@@ -8,13 +8,7 @@ Please see LICENSE in the repository root for full details.
|
||||
import { TrackReferenceOrPlaceholder } from "@livekit/components-core";
|
||||
import { animated } from "@react-spring/web";
|
||||
import { RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import {
|
||||
ComponentProps,
|
||||
ReactNode,
|
||||
forwardRef,
|
||||
useEffect,
|
||||
useState,
|
||||
} from "react";
|
||||
import { ComponentProps, ReactNode, forwardRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import classNames from "classnames";
|
||||
import { VideoTrack } from "@livekit/components-react";
|
||||
|
||||
Reference in New Issue
Block a user