Merge pull request #119 from sambecker/rsalik/main

Make admin photo queries consistent
This commit is contained in:
Sam Becker 2024-06-29 15:13:13 -07:00 committed by GitHub
commit 8bb23a583e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 18 deletions

View File

@ -91,7 +91,7 @@ export default function AdminPhotosTable({
)}> )}>
<PhotoDate {...{ <PhotoDate {...{
photo, photo,
dateType: showUpdatedAt ? 'updatedAt' : undefined, dateType: showUpdatedAt ? 'updatedAt' : 'createdAt',
}} /> }} />
</div> </div>
</div> </div>

View File

@ -21,6 +21,7 @@ export default function AdminPhotosTableInfinite({
initialOffset={initialOffset} initialOffset={initialOffset}
itemsPerPage={itemsPerPage} itemsPerPage={itemsPerPage}
useCachedPhotos={false} useCachedPhotos={false}
sortBy="createdAt"
includeHiddenPhotos includeHiddenPhotos
> >
{({ photos, onLastPhotoVisible, revalidatePhoto }) => {({ photos, onLastPhotoVisible, revalidatePhoto }) =>

View File

@ -15,6 +15,7 @@ import { clsx } from 'clsx/lite';
import { useAppState } from '@/state/AppState'; import { useAppState } from '@/state/AppState';
import { Camera } from '@/camera'; import { Camera } from '@/camera';
import { FilmSimulation } from '@/simulation'; import { FilmSimulation } from '@/simulation';
import { GetPhotosOptions } from './db';
export type RevalidatePhoto = ( export type RevalidatePhoto = (
photoId: string, photoId: string,
@ -25,6 +26,7 @@ export default function InfinitePhotoScroll({
cacheKey, cacheKey,
initialOffset, initialOffset,
itemsPerPage, itemsPerPage,
sortBy,
tag, tag,
camera, camera,
simulation, simulation,
@ -35,6 +37,7 @@ export default function InfinitePhotoScroll({
}: { }: {
initialOffset: number initialOffset: number
itemsPerPage: number itemsPerPage: number
sortBy?: GetPhotosOptions['sortBy']
tag?: string tag?: string
camera?: Camera camera?: Camera
simulation?: FilmSimulation simulation?: FilmSimulation
@ -59,25 +62,18 @@ export default function InfinitePhotoScroll({
, [key]); , [key]);
const fetcher = useCallback(([_key, size]: [string, number]) => const fetcher = useCallback(([_key, size]: [string, number]) =>
useCachedPhotos (useCachedPhotos ? getPhotosCachedAction : getPhotosAction)({
? getPhotosCachedAction({ offset: initialOffset + size * itemsPerPage,
offset: initialOffset + size * itemsPerPage, sortBy,
limit: itemsPerPage, limit: itemsPerPage,
hidden: includeHiddenPhotos ? 'include' : 'exclude', hidden: includeHiddenPhotos ? 'include' : 'exclude',
tag, tag,
camera, camera,
simulation, simulation,
}) })
: getPhotosAction({
offset: initialOffset + size * itemsPerPage,
limit: itemsPerPage,
hidden: includeHiddenPhotos ? 'include' : 'exclude',
tag,
camera,
simulation,
})
, [ , [
useCachedPhotos, useCachedPhotos,
sortBy,
initialOffset, initialOffset,
itemsPerPage, itemsPerPage,
includeHiddenPhotos, includeHiddenPhotos,