diff --git a/.peppa/memory/pep-274.md b/.peppa/memory/pep-274.md new file mode 100644 index 00000000..3a35b642 --- /dev/null +++ b/.peppa/memory/pep-274.md @@ -0,0 +1,4 @@ +# Память: PEP-274 + +## Решения +- Заголовок вкладки (PEP-274) — `pageTitle`/`projectTitle`/`taskTitle` (apps/web/lib/title.ts); page.tsx без `generateMetadata` роняет page-titles.test.ts. diff --git a/apps/web/app/(app)/chats/[chat]/page.tsx b/apps/web/app/(app)/chats/[chat]/page.tsx index a58cc650..89011044 100644 --- a/apps/web/app/(app)/chats/[chat]/page.tsx +++ b/apps/web/app/(app)/chats/[chat]/page.tsx @@ -21,12 +21,13 @@ import { AttachField } from "@/components/AttachField"; import { Workspace } from "@/components/Workspace"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/input"; -import { requireUser, words } from "@/lib/auth"; +import { currentUser, requireUser, words } from "@/lib/auth"; import { db } from "@/lib/db"; import { getT } from "@/lib/i18n"; import { cn } from "@/lib/utils"; import { cleanText, messageLink, STUCK_NOTICE } from "@/lib/chat-text"; import { chatOfferAction, linkChatAction, postChatAction, unlinkChatAction } from "../actions"; +import { pageTitle } from "@/lib/title"; type Params = { error?: string; thread?: string; link?: string; q?: string; list?: string }; @@ -34,6 +35,16 @@ const CHANNEL = "channel"; /** PEP-106: `?thread=feed` — the agents' events; no `thread` — the people's discussion. */ const FEED = "feed"; +// PEP-274: «Чат KEY — FORGE» (the chat list of the viewer — no names of chats they cannot see). +export async function generateMetadata({ params }: { params: Promise<{ chat: string }> }) { + const t = await getT(); + const user = await currentUser(); + const slug = (await params).chat; + const chat = user ? (await listChats(db, user)).find((c) => c.slug.toLowerCase() === slug.toLowerCase()) : null; + if (!chat) return pageTitle(t, t("Чаты")); + return pageTitle(t, chat.kind === "master" ? t("Все события") : t("Чат {key}", { key: chat.slug.toUpperCase() })); +} + /** «Чаты» (PEP-62): the master chat and project chats with threads; a linked Telegram group mirrors them. */ export default async function ChatPage({ params, searchParams }: { params: Promise<{ chat: string }>; searchParams: Promise }) { const user = await requireUser(); @@ -338,11 +349,12 @@ export default async function ChatPage({ params, searchParams }: { params: Promi {writable && (
-
-