Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: move logic into function for notific count (#1586)

Sean Boultb3281263c955
diff --git a/apps/web/src/components/Navigation/index.tsx b/apps/web/src/components/Navigation/index.tsx
index 6b87dc32..3ec46ee7 100644
--- a/apps/web/src/components/Navigation/index.tsx
+++ b/apps/web/src/components/Navigation/index.tsx
@@ -36,10 +36,11 @@ export function getAdminUrl() {
}
export async function Navigation() {
- const [session, featureFlags] = await Promise.all([auth(), getAllFlags()]);
-
- const notificationCount = session ? await getNotificationCount() : 0;
-
+ const [session, featureFlags, notificationCount] = await Promise.all([
+ auth(),
+ getAllFlags(),
+ getNotificationCount(),
+ ]);
const isAdminOrMod = isAdminOrModerator(session);
const isAdminRole = isAdmin(session);
diff --git a/apps/web/src/components/Navigation/navigation.actions.ts b/apps/web/src/components/Navigation/navigation.actions.ts
index 78d3fbc9..651eacc7 100644
--- a/apps/web/src/components/Navigation/navigation.actions.ts
+++ b/apps/web/src/components/Navigation/navigation.actions.ts
@@ -5,7 +5,7 @@ import { auth } from '~/server/auth';
export async function getNotificationCount() {
const session = await auth();
-
+ if (!session?.user?.id) return 0;
return prisma.notification.count({
where: {
isRead: false,