Vercel/app/admin/photos/page.tsx
Sam Becker 1e66815a3d
Albums (#315)
* Make /db top-level module

* Create Album type

* Pin pnpm version

* Generalize query modules

* Finalize album postgres data type

* Remove temp albums prop

* Create basic album primitives

* Fix temporary album bugs

* Add albums to sidebar

* Disambiguate string date utilities

* Localize album language

* Add album join option to core photo queries

* Tweak album icon placement

* Add album photo detail page

* Refine Album data model

* Display album subhead when available

* Generate album og images

* Finalize album share modal

* Add albums to sitemap

* Statically pre-render albums

* Display tags on albums

* Add albums to cmd-k menu

* Handle album tag overflow

* Stop truncating album subheads

* Create core admin album views

* Make albums editable

* Create/edit albums on photo save, add delete album
2025-09-16 21:47:22 -05:00

63 lines
1.8 KiB
TypeScript

import { getStoragePhotoUrlsNoStore } from '@/platforms/storage/cache';
import { getPhotos, getPhotosInNeedOfUpdateCount } from '@/photo/query';
import { getPhotosMetaCached } from '@/photo/cache';
import AdminPhotosClient from '@/admin/AdminPhotosClient';
import { revalidatePath } from 'next/cache';
import { cookies } from 'next/headers';
import { TIMEZONE_COOKIE_NAME } from '@/utility/timezone';
import {
AI_CONTENT_GENERATION_ENABLED,
PRESERVE_ORIGINAL_UPLOADS,
} from '@/app/config';
export const maxDuration = 60;
const DEBUG_PHOTO_BLOBS = false;
const INFINITE_SCROLL_INITIAL_ADMIN_PHOTOS = 25;
const INFINITE_SCROLL_MULTIPLE_ADMIN_PHOTOS = 50;
export default async function AdminPhotosPage() {
const timezone = (await cookies()).get(TIMEZONE_COOKIE_NAME)?.value;
const [
photos,
photosCount,
photosCountNeedsSync,
blobPhotoUrls,
] = await Promise.all([
getPhotos({
hidden: 'include',
sortBy: 'createdAt',
limit: INFINITE_SCROLL_INITIAL_ADMIN_PHOTOS,
}).catch(() => []),
getPhotosMetaCached({ hidden: 'include'})
.then(({ count }) => count)
.catch(() => 0),
getPhotosInNeedOfUpdateCount()
.catch(() => 0),
DEBUG_PHOTO_BLOBS
? getStoragePhotoUrlsNoStore()
: [],
]);
return (
<AdminPhotosClient {...{
photos,
photosCount,
photosCountNeedsSync,
shouldResize: !PRESERVE_ORIGINAL_UPLOADS,
hasAiTextGeneration: AI_CONTENT_GENERATION_ENABLED,
onLastUpload: async () => {
'use server';
// Update upload count in admin nav
revalidatePath('/admin', 'layout');
},
blobPhotoUrls,
infiniteScrollInitial: INFINITE_SCROLL_INITIAL_ADMIN_PHOTOS,
infiniteScrollMultiple: INFINITE_SCROLL_MULTIPLE_ADMIN_PHOTOS,
timezone,
}} />
);
}