Make /about/edit safely pre-render

This commit is contained in:
Sam Becker 2026-03-01 13:33:44 -06:00
parent 915b19bb54
commit bd2dd6a030
2 changed files with 22 additions and 16 deletions

View File

@ -24,23 +24,29 @@ export default async function AboutEditPage() {
photosCount, photosCount,
photosHidden, photosHidden,
] = await Promise.all([ ] = await Promise.all([
getAbout().then(async about => { getAbout()
const photoAvatar = about?.photoIdAvatar .then(async about => {
? await getPhoto(about?.photoIdAvatar ?? '', true) const photoAvatar = about?.photoIdAvatar
.catch(() => undefined) ? await getPhoto(about?.photoIdAvatar ?? '', true)
: undefined; .catch(() => undefined)
: undefined;
const photoHero = about?.photoIdHero const photoHero = about?.photoIdHero
? await getPhoto(about?.photoIdHero ?? '', true) ? await getPhoto(about?.photoIdHero ?? '', true)
.catch(() => undefined) .catch(() => undefined)
: undefined; : undefined;
return { return {
about, about,
photoAvatar, photoAvatar,
photoHero, photoHero,
}; };
}), })
.catch(() => ({
about: undefined,
photoAvatar: undefined,
photoHero: undefined,
})),
getPhotosCached(PHOTO_CHOOSER_QUERY_OPTIONS) getPhotosCached(PHOTO_CHOOSER_QUERY_OPTIONS)
.catch(() => []), .catch(() => []),
getPhotosMetaCached(PHOTO_CHOOSER_QUERY_OPTIONS) getPhotosMetaCached(PHOTO_CHOOSER_QUERY_OPTIONS)

View File

@ -67,7 +67,7 @@ export default function AdminAboutEditPage({
label="Avatar Photo" label="Avatar Photo"
value={aboutForm?.photoIdAvatar ?? ''} value={aboutForm?.photoIdAvatar ?? ''}
onChange={photoIdAvatar => setAboutForm(form => onChange={photoIdAvatar => setAboutForm(form =>
({ ...form, photoIdAvatar: convertUrlToPhotoId(photoIdAvatar) }))} ({ ...form, photoIdAvatar }))}
photo={photoAvatar} photo={photoAvatar}
photos={photos} photos={photos}
photosCount={photosCount} photosCount={photosCount}