Dedupe photo requests in film simulations
This commit is contained in:
parent
db801237b3
commit
d74293e31e
@ -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); }
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user