From 75200c9b2ba89497058de010192abc1663b67960 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 18 May 2024 16:10:11 -0500 Subject: [PATCH] Fix entity-based infinite scroll queries --- src/photo/InfinitePhotoScroll.tsx | 11 +++++++++++ src/photo/PhotoGridInfinite.tsx | 9 +++++++++ src/photo/PhotoGridPage.tsx | 15 ++++++++++++++- src/simulation/FilmSimulationOverview.tsx | 1 + src/tag/TagOverview.tsx | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/photo/InfinitePhotoScroll.tsx b/src/photo/InfinitePhotoScroll.tsx index 57ba63a1..72fe66bf 100644 --- a/src/photo/InfinitePhotoScroll.tsx +++ b/src/photo/InfinitePhotoScroll.tsx @@ -14,6 +14,7 @@ import { Photo } from '.'; import { clsx } from 'clsx/lite'; import { useAppState } from '@/state/AppState'; import { Camera } from '@/camera'; +import { FilmSimulation } from '@/simulation'; export type RevalidatePhoto = ( photoId: string, @@ -24,7 +25,9 @@ export default function InfinitePhotoScroll({ cacheKey, initialOffset, itemsPerPage, + tag, camera, + simulation, wrapMoreButtonInGrid, useCachedPhotos = true, includeHiddenPhotos, @@ -32,7 +35,9 @@ export default function InfinitePhotoScroll({ }: { initialOffset: number itemsPerPage: number + tag?: string camera?: Camera + simulation?: FilmSimulation cacheKey: string wrapMoreButtonInGrid?: boolean useCachedPhotos?: boolean @@ -59,20 +64,26 @@ export default function InfinitePhotoScroll({ offset: initialOffset + size * itemsPerPage, limit: itemsPerPage, hidden: includeHiddenPhotos ? 'include' : 'exclude', + tag, camera, + simulation, }) : getPhotosAction({ offset: initialOffset + size * itemsPerPage, limit: itemsPerPage, hidden: includeHiddenPhotos ? 'include' : 'exclude', + tag, camera, + simulation, }) , [ useCachedPhotos, initialOffset, itemsPerPage, includeHiddenPhotos, + tag, camera, + simulation, ]); const { data, isLoading, isValidating, error, mutate, setSize } = diff --git a/src/photo/PhotoGridInfinite.tsx b/src/photo/PhotoGridInfinite.tsx index 76b4e95a..339604a4 100644 --- a/src/photo/PhotoGridInfinite.tsx +++ b/src/photo/PhotoGridInfinite.tsx @@ -4,16 +4,21 @@ import { Camera } from '@/camera'; import { INFINITE_SCROLL_MULTIPLE_GRID } from '.'; import InfinitePhotoScroll from './InfinitePhotoScroll'; import PhotoGrid from './PhotoGrid'; +import { FilmSimulation } from '@/simulation'; export default function PhotoGridInfinite({ cacheKey, initialOffset, + tag, camera, + simulation, animateOnFirstLoadOnly, }: { cacheKey: string initialOffset: number + tag?: string camera?: Camera + simulation?: FilmSimulation animateOnFirstLoadOnly?: boolean }) { return ( @@ -21,12 +26,16 @@ export default function PhotoGridInfinite({ cacheKey={cacheKey} initialOffset={initialOffset} itemsPerPage={INFINITE_SCROLL_MULTIPLE_GRID} + tag={tag} camera={camera} + simulation={simulation} > {({ photos, onLastPhotoVisible }) => } diff --git a/src/photo/PhotoGridPage.tsx b/src/photo/PhotoGridPage.tsx index ced9a49a..a17c0097 100644 --- a/src/photo/PhotoGridPage.tsx +++ b/src/photo/PhotoGridPage.tsx @@ -5,12 +5,15 @@ import PhotoGridInfinite from './PhotoGridInfinite'; import { Camera } from '@/camera'; import { clsx } from 'clsx/lite'; import AnimateItems from '@/components/AnimateItems'; +import { FilmSimulation } from '@/simulation'; export default function PhotoGridPage({ cacheKey, photos, count, + tag, camera, + simulation, animateOnFirstLoadOnly, header, sidebar, @@ -18,7 +21,9 @@ export default function PhotoGridPage({ cacheKey: string photos: Photo[] count: number + tag?: string camera?: Camera + simulation?: FilmSimulation animateOnFirstLoadOnly?: boolean header?: JSX.Element sidebar?: JSX.Element @@ -35,12 +40,20 @@ export default function PhotoGridPage({ animateOnFirstLoadOnly />}
- + {count > photos.length && }
diff --git a/src/simulation/FilmSimulationOverview.tsx b/src/simulation/FilmSimulationOverview.tsx index 2f2da7ce..37fa71fe 100644 --- a/src/simulation/FilmSimulationOverview.tsx +++ b/src/simulation/FilmSimulationOverview.tsx @@ -21,6 +21,7 @@ export default function FilmSimulationOverview({ cacheKey: `simulation-${simulation}`, photos, count, + simulation, header: