import React, { useCallback, useEffect, useState } from "react"; import classNames from "classnames"; import styles from "./PTTButton.module.css"; import { ReactComponent as MicIcon } from "../icons/Mic.svg"; import { Avatar } from "../Avatar"; export function PTTButton({ showTalkOverError, activeSpeakerUserId, activeSpeakerDisplayName, activeSpeakerAvatarUrl, activeSpeakerIsLocalUser, size, startTalking, stopTalking, }) { const [isHeld, setHeld] = useState(false); const onDocumentMouseUp = useCallback(() => { //if (isHeld) stopTalking(); setHeld(false); }, [isHeld, setHeld]); const onButtonMouseDown = useCallback(() => { setHeld(true); startTalking(); }, [setHeld]); useEffect(() => { window.addEventListener("mouseup", onDocumentMouseUp); return () => { window.removeEventListener("mouseup", onDocumentMouseUp); }; }, [onDocumentMouseUp]); return ( ); }