Dedupe photo requests in film simulations

This commit is contained in:
Sam Becker 2024-03-04 08:38:48 -06:00
parent db801237b3
commit d74293e31e

View File

@ -11,10 +11,13 @@ import {
} from '@/site/paths';
import PhotoDetailPage from '@/photo/PhotoDetailPage';
import { getPhotoCached } from '@/photo/cache';
import { ReactNode } from 'react';
import { ReactNode, cache } from 'react';
import { FilmSimulation } from '@/simulation';
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
export const getPhotoCachedCached =
cache((photoId: string) => getPhotoCached(photoId));
interface PhotoFilmSimulationProps {
params: { photoId: string, simulation: FilmSimulation }
}
@ -22,7 +25,7 @@ interface PhotoFilmSimulationProps {
export async function generateMetadata({
params: { photoId, simulation },
}: PhotoFilmSimulationProps): Promise<Metadata> {
const photo = await getPhotoCached(photoId);
const photo = await getPhotoCachedCached(photoId);
if (!photo) { return {}; }
@ -53,7 +56,7 @@ export default async function PhotoFilmSimulationPage({
params: { photoId, simulation },
children,
}: PhotoFilmSimulationProps & { children: ReactNode }) {
const photo = await getPhotoCached(photoId);
const photo = await getPhotoCachedCached(photoId);
if (!photo) { redirect(PATH_ROOT); }