diff --git a/src/common/component/FileMessage/VideoMessage.tsx b/src/common/component/FileMessage/VideoMessage.tsx index 852c3583..997b547c 100644 --- a/src/common/component/FileMessage/VideoMessage.tsx +++ b/src/common/component/FileMessage/VideoMessage.tsx @@ -1,4 +1,4 @@ -import { useRef, useState } from 'react'; +import { SyntheticEvent } from 'react'; import { formatBytes } from '../../utils'; import IconDownload from "../../../assets/icons/download.svg"; import IconVideo from "../../../assets/icons/file.video.svg"; @@ -11,36 +11,33 @@ type Props = { } const VideoMessage = ({ url, name, size, download }: Props) => { - const videoRef = useRef(null); - const [playing, setPlaying] = useState(false); const _size = formatBytes(size); - const handlePlaying = () => { - setPlaying(true); - }; - const handlePause = () => { - if (videoRef && videoRef.current) { - if (videoRef.current.seeking) return; + const handlePlay = (evt: SyntheticEvent) => { + const infoEle = evt.currentTarget.previousSibling; + if (infoEle) { + (infoEle as HTMLDivElement).classList.add("hidden"); + } + }; + const handlePause = (evt: SyntheticEvent) => { + const infoEle = evt.currentTarget.previousSibling; + if (infoEle) { + (infoEle as HTMLDivElement).classList.remove("hidden"); } - setPlaying(false); }; return (
- {!playing && - <> -
-
-
- -
- {name} - {_size} -
-
- +
+
+
+ +
+ {name} + {_size}
- - } -
+ +
+
); };