Add error resiliency to homepage, nav, and footer
This commit is contained in:
parent
4d5249cc08
commit
e88d4cfad4
@ -16,7 +16,9 @@ import { MAX_PHOTOS_TO_SHOW_OG } from '@/photo/image-response';
|
||||
export const runtime = 'edge';
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const photos = await getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG });
|
||||
// Make homepage queries resilient to error on first time setup
|
||||
const photos = await getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG })
|
||||
.catch(() => []);
|
||||
return generateOgImageMetaForPhotos(photos);
|
||||
}
|
||||
|
||||
@ -27,8 +29,7 @@ export default async function HomePage({ searchParams }: PaginationParams) {
|
||||
photos,
|
||||
count,
|
||||
] = await Promise.all([
|
||||
// Make homepage queries resilient to error
|
||||
// for initial setup when database may not exist
|
||||
// Make homepage queries resilient to error on first time setup
|
||||
getPhotosCached({ limit }).catch(() => []),
|
||||
getPhotosCountCached().catch(() => 0),
|
||||
]);
|
||||
|
||||
@ -2,7 +2,8 @@ import { authCached } from '@/cache';
|
||||
import FooterClient from './FooterClient';
|
||||
|
||||
export default async function Footer() {
|
||||
const session = await authCached();
|
||||
// Make footer auth resilient to error on first time setup
|
||||
const session = await authCached().catch(() => null);
|
||||
return (
|
||||
<FooterClient userEmail={session?.user?.email} />
|
||||
);
|
||||
|
||||
@ -2,7 +2,8 @@ import { authCached } from '@/cache';
|
||||
import NavClient from './NavClient';
|
||||
|
||||
export default async function Nav() {
|
||||
const session = await authCached();
|
||||
// Make nav auth resilient to error on first time setup
|
||||
const session = await authCached().catch(() => null);
|
||||
return (
|
||||
<NavClient showAdmin={Boolean(session?.user?.email)} />
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user