From 936b920dbb3b9763dcf9854977e4d558fa9cebb6 Mon Sep 17 00:00:00 2001 From: Alexander Druz Date: Fri, 2 Aug 2024 13:29:51 +0200 Subject: [PATCH] Do not set repeat mode if backend is not yet ready --- src/components/shared/AudioViewer/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/shared/AudioViewer/index.tsx b/src/components/shared/AudioViewer/index.tsx index 9cffdc4f..4c73f08b 100644 --- a/src/components/shared/AudioViewer/index.tsx +++ b/src/components/shared/AudioViewer/index.tsx @@ -338,13 +338,19 @@ const AudioViewer = ({ ]); useEffect(() => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (waveform.current?.backend as any).media.loop = repeat; if (isReady && autoplay && !waveform.current?.isPlaying()) { switchActiveWidget(); waveform.current?.play(); } - }, [isReady, autoplay, repeat]); + }, [isReady, autoplay]); + + useEffect(() => { + const backend = waveform.current?.backend; + if (backend) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (backend as any).media.loop = repeat; + } + }, [isReady, repeat]); useEffect(() => { if (!waveform.current?.isReady) return;