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 (
@@ -49,7 +63,7 @@ export default async function ContactsPage() {
- + ); } diff --git a/src/components/frontend/personnel/NpcCard.tsx b/src/components/frontend/personnel/NpcCard.tsx index ce8d23a6..77cca4b8 100644 --- a/src/components/frontend/personnel/NpcCard.tsx +++ b/src/components/frontend/personnel/NpcCard.tsx @@ -9,9 +9,11 @@ import { initialsOf } from "@/components/frontend/personnel/initials"; interface NpcCardProps { readonly npc: GameNpc; + /** This contact offers conversation content the player has never read. */ + readonly unread?: boolean; } -export function NpcCard({ npc }: NpcCardProps) { +export function NpcCard({ npc, unread = false }: NpcCardProps) { const factionName = typeof npc.faction === "object" && npc.faction !== null ? npc.faction.name : null; const locationName = @@ -33,7 +35,7 @@ export function NpcCard({ npc }: NpcCardProps) { return (
@@ -41,6 +43,18 @@ export function NpcCard({ npc }: NpcCardProps) { + {/* New conversation content. Positioned over the portrait rather than in + the readout footer, which is already three cells wide. */} + {unread && ( +