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.
This commit is contained in:
infinite-persistence 2021-06-26 01:03:49 +08:00
parent c44beaf8fa
commit e367b66a08
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -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)}`);