fix: back to prefetch
This commit is contained in:
1 parent
a268f7c38d
commit
c9ca262da8
14 files changed
+180
-27
No files matched your search
@@ -1,12 +1,18 @@
|
||||
'use client';
|
||||
|
||||
import { FC } from 'react';
|
||||
|
||||
import Preview from '../Preview';
|
||||
|
||||
import Carousel from './components/Carousel';
|
||||
import useRandomMovie from './useRandomMovie';
|
||||
|
||||
const Random = () => {
|
||||
const { movie, movies, onIndexChange, fetchNextPage } = useRandomMovie();
|
||||
interface Props {
|
||||
page: number;
|
||||
}
|
||||
|
||||
const Random: FC<Props> = ({ page }) => {
|
||||
const { movie, movies, onIndexChange, fetchNextPage } = useRandomMovie({ page });
|
||||
|
||||
return (
|
||||
<Preview
|
||||
|
||||
@@ -10,10 +10,14 @@ const indexAtom = atom(0);
|
||||
|
||||
export const useSilentIndex = () => getDefaultStore().get(indexAtom);
|
||||
|
||||
const useRandomMovie = () => {
|
||||
interface Props {
|
||||
page: number;
|
||||
}
|
||||
|
||||
const useRandomMovie = ({ page }: Props) => {
|
||||
const [index, setIndex] = useAtom(indexAtom);
|
||||
|
||||
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery());
|
||||
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery({ page }));
|
||||
|
||||
if (movies.length && !movies[index]) {
|
||||
setIndex(0);
|
||||
|
||||
Reference in new issue
Block a user