diff --git a/src/app/(frontend)/personnel/contacts/page.tsx b/src/app/(frontend)/personnel/contacts/page.tsx index 3f89c24d..b7cbbda6 100644 --- a/src/app/(frontend)/personnel/contacts/page.tsx +++ b/src/app/(frontend)/personnel/contacts/page.tsx @@ -4,6 +4,8 @@ import { headers as nextHeaders } from "next/headers"; import type { GameNpc } from "@/payload-types"; import { UsersIcon } from "lucide-react"; import { NpcDirectory } from "@/components/frontend/personnel/NpcDirectory"; +import { loadUnreadNpcIds } from "@/lib/npc-dialogue/unread"; +import { canSeeTestingDialogues } from "@/lib/npc-dialogue/visibility"; import { ClassificationStrip, CornerBrackets, DOSSIER } from "@/components/frontend/operations"; export const metadata = { @@ -24,6 +26,18 @@ export default async function ContactsPage() { }); const npcs = npcsRes.docs as unknown as GameNpc[]; + // Which contacts have conversation content this player has never opened. Two + // queries for the whole page, not one per card, and the same gates the offer + // uses: `canMessage` first, because a contact that cannot start a + // conversation should not advertise one, then the entry gate and testing + // flag inside the loader. + const canSeeTesting = await canSeeTestingDialogues(payload, user); + const unreadNpcIds = await loadUnreadNpcIds(payload, { + npcIds: npcs.filter((npc) => npc.canMessage === true).map((npc) => npc.id), + userId: user?.id ?? null, + canSeeTesting, + }).catch(() => []); + return (