diff --git a/src/components/PresignedImage.tsx b/src/components/PresignedImage.tsx new file mode 100644 index 0000000..9cb5871 --- /dev/null +++ b/src/components/PresignedImage.tsx @@ -0,0 +1,18 @@ +import { type FC, type ImgHTMLAttributes } from "react"; +import { usePresignedUrl } from "@/pages/uploader/hooks/usePresignedUrl"; + +type Props = ImgHTMLAttributes & { + src?: string; +}; + +const PresignedImage: FC = ({ src, alt = "", ...props }) => { + const resolvedSrc = usePresignedUrl(src); + + if (!resolvedSrc) { + return null; + } + + return {alt}; +}; + +export default PresignedImage; diff --git a/src/components/VoicePlayer.tsx b/src/components/VoicePlayer.tsx index b96fab0..f4ac9d0 100644 --- a/src/components/VoicePlayer.tsx +++ b/src/components/VoicePlayer.tsx @@ -1,18 +1,20 @@ import { Pause, Play } from "iconsax-react" import { useEffect, useRef, useState, type FC } from "react" +import { usePresignedUrl } from "@/pages/uploader/hooks/usePresignedUrl" type VoicePlayerProps = { url: string } const VoicePlayer: FC = ({ url }) => { + const resolvedUrl = usePresignedUrl(url) const audioRef = useRef(null) const [isPlaying, setIsPlaying] = useState(false) const [progress, setProgress] = useState(0) useEffect(() => { const audio = audioRef.current - if (!audio) return + if (!audio || !resolvedUrl) return const update = () => { if (!audio.duration) return @@ -28,7 +30,7 @@ const VoicePlayer: FC = ({ url }) => { return () => { audio.removeEventListener('timeupdate', update) } - }, []) + }, [resolvedUrl]) const toggle = () => { if (!audioRef.current) return @@ -66,9 +68,9 @@ const VoicePlayer: FC = ({ url }) => { })} -