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 {...{
photo,
dateType: showUpdatedAt ? 'updatedAt' : undefined,
dateType: showUpdatedAt ? 'updatedAt' : 'createdAt',
}} />
</div>
</div>

View File

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

View File

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