From 7a6af6c07282aa3d37f6a191e631b4ae602087f4 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 19 May 2023 19:41:20 +0200 Subject: [PATCH] remove unnecesary eslint ignore --- .../components/actions/CaptionRendererAction.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/video/components/actions/CaptionRendererAction.tsx b/src/video/components/actions/CaptionRendererAction.tsx index 617ad83d..8858ee28 100644 --- a/src/video/components/actions/CaptionRendererAction.tsx +++ b/src/video/components/actions/CaptionRendererAction.tsx @@ -53,6 +53,11 @@ export function CaptionRendererAction({ const { captionSettings, setCaptionDelay } = useSettings(); const captions = useRef([]); + const captionSetRef = useRef<(delay: number) => void>(setCaptionDelay); + useEffect(() => { + captionSetRef.current = setCaptionDelay; + }, [setCaptionDelay]); + useAsync(async () => { const blobUrl = source?.caption?.url; if (blobUrl) { @@ -69,11 +74,12 @@ export function CaptionRendererAction({ captions.current = []; } }, [source?.caption?.url]); + + // reset delay when loading new source url useEffect(() => { - // reset delay after video ends - return () => setCaptionDelay(0); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + captionSetRef.current(0); + }, [source?.caption?.url]); + const isVisible = useCallback( ( start: number,