fix: apply fetchpriority=high to the actual LCP carousel poster

The hero overlay only renders when the random-movie index is non-zero,
but the index atom defaults to 0 — so on a fresh load the LCP element
was actually the first Virtuoso carousel item, which lacked `priority`.
Track the initial index and mark only that item's poster as high
priority, covering both the index===0 and index!==0 first-paint paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nerandClaude Sonnet 4.6 committed 2026-06-06 23:17:37 +03:00
1 parent 07bbb576f6
commit 692f5ab4e3
1 file changed
+5 -2
@@ -12,6 +12,7 @@ import { useSilentIndex } from '../../useRandomMovie';
interface Context {
onIndexChange: (index: number) => void;
gap?: number;
initialIndex?: number;
}
interface Props extends Context {
@@ -23,6 +24,7 @@ const Carousel = memo(
function Carousel({ shows, gap = 8, onIndexChange, onEndReached }: Props) {
const index = useSilentIndex();
const [loaded, setLoaded] = useState(!index);
const initialIndexRef = useRef(index);
const context = useMemo(
() => ({
@@ -33,7 +35,8 @@ const Carousel = memo(
startTransition(() => setLoaded(true));
},
gap
gap,
initialIndex: initialIndexRef.current
}),
[onIndexChange, gap, loaded, index]
);
@@ -89,7 +92,7 @@ const components: VirtuosoProps<Show, Context>['components'] = {
return (
<div {...props} ref={ref} className='snap-start'>
<Poster lazy={false} show={item} className='static-aspect-ratio' />
<Poster lazy={false} priority={index === context?.initialIndex} show={item} className='static-aspect-ratio' />
</div>
);
},