From e367b66a0831317d353ab8ddbf3144045ae7d516 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Sat, 26 Jun 2021 01:03:49 +0800 Subject: [PATCH] Fix stuck video poster when switching videos ## Issue With autoplay off, clicking on another video from the Recommended section didn't update the video poster. ## Fix Made a mistake assuming that the whole component will be re-mounted, so was only setting the thumbnail once. --- ui/component/fileRenderInitiator/view.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/component/fileRenderInitiator/view.jsx b/ui/component/fileRenderInitiator/view.jsx index e3ac0204f..732e83125 100644 --- a/ui/component/fileRenderInitiator/view.jsx +++ b/ui/component/fileRenderInitiator/view.jsx @@ -85,15 +85,17 @@ export default function FileRenderInitiator(props: Props) { containerRef.current.parentElement && containerRef.current.parentElement.offsetWidth ) { - const dimen = containerRef.current.parentElement.offsetWidth; - newThumbnail = getThumbnailCdnUrl({ thumbnail: newThumbnail, width: dimen, height: dimen }); + const w = containerRef.current.parentElement.offsetWidth; + newThumbnail = getThumbnailCdnUrl({ thumbnail: newThumbnail, width: w, height: w }); } // @endif - setThumbnail(newThumbnail); + if (newThumbnail !== thumbnail) { + setThumbnail(newThumbnail); + } }, 200); } - }, []); // eslint-disable-line react-hooks/exhaustive-deps + }, [claimThumbnail]); function doAuthRedirect() { history.push(`/$/${PAGES.AUTH}?redirect=${encodeURIComponent(location.pathname)}`);