From 8c5a1d15cb899cbac78641d5027390c1e40f9747 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:12:52 +0530 Subject: [PATCH] fix negative audio duration info crash react-range (#1701) --- src/app/organisms/room/message/AudioContent.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/organisms/room/message/AudioContent.tsx b/src/app/organisms/room/message/AudioContent.tsx index eae5447..83e5dc0 100644 --- a/src/app/organisms/room/message/AudioContent.tsx +++ b/src/app/organisms/room/message/AudioContent.tsx @@ -45,7 +45,8 @@ export const AudioContent = as<'div', AudioContentProps>( const [currentTime, setCurrentTime] = useState(0); // duration in seconds. (NOTE: info.duration is in milliseconds) - const [duration, setDuration] = useState((info.duration ?? 0) / 1000); + const infoDuration = info.duration ?? 0; + const [duration, setDuration] = useState((infoDuration >= 0 ? infoDuration : 0) / 1000); const getAudioRef = useCallback(() => audioRef.current, []); const { loading } = useMediaLoading(getAudioRef);