diff --git a/src/app/page.tsx b/src/app/page.tsx index 79279dc8..a110e4a9 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,9 +3,9 @@ import { LARGE_PHOTOS_TO_SHOW, generateOgImageMetaForPhotos } from '@/photo'; import PhotosEmptyState from '@/photo/PhotosEmptyState'; import { Metadata } from 'next/types'; import { MAX_PHOTOS_TO_SHOW_OG } from '@/photo/image-response'; -import MoreComponents from '@/components/MoreComponents'; import PhotosLarge from '@/photo/PhotosLarge'; import { Suspense } from 'react'; +import { MorePhotosLarge } from '@/photo/MorePhotosLarge'; export const revalidate = 3600; @@ -31,24 +31,10 @@ export default async function HomePage() { ?
- { - 'use server'; - const photos = await getPhotosCached({ limit: offset + limit }) - .catch(() => undefined); - if (!photos) { - return { didError: true }; - } else { - const nextPhotos = photos.slice(offset); - return { - nextComponent: , - isFinished: offset + limit >= count, - }; - } - }} + totalPhotosCount={count} />
diff --git a/src/components/MoreComponents.tsx b/src/components/MoreComponents.tsx index 9eb55924..112850b4 100644 --- a/src/components/MoreComponents.tsx +++ b/src/components/MoreComponents.tsx @@ -21,7 +21,7 @@ export default function MoreComponents({ getNextComponent: (offset: number, limit: number) => Promise<{ nextComponent?: JSX.Element, isFinished?: boolean, - didError?: boolean, + didFail?: boolean, }> label?: string triggerOnView?: boolean @@ -63,8 +63,8 @@ export default function MoreComponents({ initialOffset + (indexToLoad - 1) * itemsPerRequest, itemsPerRequest, ) - .then(({ nextComponent, isFinished, didError }) => { - if (!didError && nextComponent) { + .then(({ nextComponent, isFinished, didFail }) => { + if (!didFail && nextComponent) { setComponents(current => { const updatedComponents = [...current]; updatedComponents[indexToLoad] = nextComponent; diff --git a/src/photo/MorePhotosLarge.tsx b/src/photo/MorePhotosLarge.tsx new file mode 100644 index 00000000..d460a869 --- /dev/null +++ b/src/photo/MorePhotosLarge.tsx @@ -0,0 +1,35 @@ +import MoreComponents from '@/components/MoreComponents'; +import PhotosLarge from './PhotosLarge'; +import { getPhotosCached } from '@/cache'; + +export function MorePhotosLarge({ + initialOffset, + itemsPerRequest, + totalPhotosCount, +}: { + initialOffset: number + itemsPerRequest: number + totalPhotosCount: number +}) { + return ( + { + 'use server'; + const photos = await getPhotosCached({ limit: offset + limit }) + .catch(() => undefined); + if (!photos) { + return { didFail: true }; + } else { + const nextPhotos = photos.slice(offset); + return { + nextComponent: , + isFinished: offset + limit >= totalPhotosCount, + }; + } + }} + /> + ); +}