Fix simulation next/previous links

This commit is contained in:
Sam Becker 2023-11-06 10:19:00 -06:00
parent 1a9980700c
commit bb1cf04218
3 changed files with 13 additions and 3 deletions

View File

@ -102,6 +102,7 @@ export default function PhotoDetailPage({
photos,
tag,
camera,
simulation,
}} />
</div>}
/>

View File

@ -7,11 +7,13 @@ import { AnimationConfig } from '../components/AnimateItems';
import { useAppState } from '@/state';
import { pathForPhoto } from '@/site/paths';
import { Camera } from '@/camera';
import { FilmSimulation } from '@/simulation';
export default function PhotoLink({
photo,
tag,
camera,
simulation,
prefetch,
nextPhotoAnimation,
children,
@ -19,6 +21,7 @@ export default function PhotoLink({
photo?: Photo
tag?: string
camera?: Camera
simulation?: FilmSimulation
prefetch?: boolean
nextPhotoAnimation?: AnimationConfig
children: ReactNode
@ -28,7 +31,7 @@ export default function PhotoLink({
return (
photo
? <Link
href={pathForPhoto(photo, tag, camera)}
href={pathForPhoto(photo, tag, camera, simulation)}
prefetch={prefetch}
onClick={() => {
if (nextPhotoAnimation) {

View File

@ -8,6 +8,7 @@ import { pathForPhoto } from '@/site/paths';
import { useAppState } from '@/state';
import { AnimationConfig } from '@/components/AnimateItems';
import { Camera } from '@/camera';
import { FilmSimulation } from '@/simulation';
const LISTENER_KEYUP = 'keyup';
@ -19,11 +20,13 @@ export default function PhotoLinks({
photos,
tag,
camera,
simulation,
}: {
photo: Photo
photos: Photo[]
tag?: string
camera?: Camera
simulation?: FilmSimulation
}) {
const router = useRouter();
@ -40,7 +43,7 @@ export default function PhotoLinks({
if (previousPhoto) {
setNextPhotoAnimation?.(ANIMATION_RIGHT);
router.push(
pathForPhoto(previousPhoto, tag, camera),
pathForPhoto(previousPhoto, tag, camera, simulation),
{ scroll: false },
);
}
@ -50,7 +53,7 @@ export default function PhotoLinks({
if (nextPhoto) {
setNextPhotoAnimation?.(ANIMATION_LEFT);
router.push(
pathForPhoto(nextPhoto, tag, camera),
pathForPhoto(nextPhoto, tag, camera, simulation),
{ scroll: false },
);
}
@ -66,6 +69,7 @@ export default function PhotoLinks({
nextPhoto,
tag,
camera,
simulation,
]);
return (
@ -75,6 +79,7 @@ export default function PhotoLinks({
nextPhotoAnimation={ANIMATION_RIGHT}
tag={tag}
camera={camera}
simulation={simulation}
prefetch
>
PREV
@ -84,6 +89,7 @@ export default function PhotoLinks({
nextPhotoAnimation={ANIMATION_LEFT}
tag={tag}
camera={camera}
simulation={simulation}
prefetch
>
NEXT