diff --git a/src/admin/AdminOutdatedClient.tsx b/src/admin/AdminOutdatedClient.tsx index cfc19923..2f5d9e1e 100644 --- a/src/admin/AdminOutdatedClient.tsx +++ b/src/admin/AdminOutdatedClient.tsx @@ -12,7 +12,7 @@ import { syncPhotosAction } from '@/photo/actions'; import { useRouter } from 'next/navigation'; import ResponsiveText from '@/components/primitives/ResponsiveText'; -const UPDATE_BATCH_SIZE = 4; +const UPDATE_BATCH_SIZE_MAX = 4; export default function AdminOutdatedClient({ photos, @@ -21,6 +21,8 @@ export default function AdminOutdatedClient({ photos: Photo[] hasAiTextGeneration: boolean }) { + const updateBatchSize = Math.min(UPDATE_BATCH_SIZE_MAX, photos.length); + const [photoIdsSyncing, setPhotoIdsSyncing] = useState([]); const arePhotoIdsSyncing = photoIdsSyncing.length > 0; @@ -46,10 +48,10 @@ export default function AdminOutdatedClient({ onClick={async () => { if (window.confirm( // eslint-disable-next-line max-len - `Are you sure you want to sync the oldest ${UPDATE_BATCH_SIZE} photos? This action cannot be undone.` + `Are you sure you want to sync the oldest ${updateBatchSize} photos? This action cannot be undone.` )) { const photosToSync = photos - .slice(0, UPDATE_BATCH_SIZE) + .slice(0, updateBatchSize) .map(photo => photo.id); const isFinalBatch = photosToSync.length >= photos.length; setPhotoIdsSyncing(photosToSync); @@ -68,8 +70,8 @@ export default function AdminOutdatedClient({ > {arePhotoIdsSyncing ? 'Syncing' - : - Sync Next {UPDATE_BATCH_SIZE} Photos + : + Sync Next {updateBatchSize} Photos } } > @@ -102,4 +104,4 @@ export default function AdminOutdatedClient({ ); -} \ No newline at end of file +} diff --git a/src/app/p/[photoId]/image/route.tsx b/src/app/p/[photoId]/image/route.tsx index 60ceefd1..288c328a 100644 --- a/src/app/p/[photoId]/image/route.tsx +++ b/src/app/p/[photoId]/image/route.tsx @@ -12,7 +12,7 @@ import { isNextImageReadyBasedOnPhotos } from '@/photo'; export let generateStaticParams: (() => Promise<{ photoId: string }[]>) | undefined = undefined; -if (STATICALLY_OPTIMIZED_OG_IMAGES && IS_PRODUCTION) { +if (STATICALLY_OPTIMIZED_OG_IMAGES && IS_PRODUCTION) { generateStaticParams = async () => { const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT }); return photos.map(photoId => ({ photoId }));