"use client"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { RefreshCwIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Empty, EmptyHeader, EmptyTitle, EmptyDescription } from "@/components/ui/empty"; import type { CommentPage } from "@/lib/comments/types"; import { CommentPushPrompt } from "./comment-push-prompt"; import { CommentComposer } from "./comment-composer"; import { CommentCard, CommentThread } from "./comment-card"; import { commentSignInHref } from "./client"; import { CommentSkeleton } from "./comment-skeleton"; import { useCommentEvents } from "./use-comment-events"; import { useCommentFeed } from "./use-comment-feed"; export function CommentBoard({ target, initial }: { target: string; initial: CommentPage }) { const router = useRouter(); const [sort, setSort] = useState("top"); const [linkedReply, setLinkedReply] = useState(null); const [linkedThread, setLinkedThread] = useState(null); const feed = useCommentFeed(`/api/comments?target=${encodeURIComponent(target)}&sort=${sort}`, initial); useCommentEvents({ target }, (changed) => feed.refresh({ silent: true, forceRevision: changed })); useEffect(() => { const showThread = () => { const match = /^#comment-([0-9a-f-]{36})$/i.exec(window.location.hash); if (match) { setLinkedThread(match[1]); const reply = new URLSearchParams(window.location.search).get("reply"); setLinkedReply(reply && /^[0-9a-f-]{36}$/i.test(reply) ? reply : null); } }; showThread(); window.addEventListener("hashchange", showThread); return () => window.removeEventListener("hashchange", showThread); }, []); return
{feed.page.viewer && }
{feed.page.viewer?.name?.slice(0, 2) || "คุณ"}
{feed.page.viewer ? void feed.refresh()} /> :

เข้าสู่ระบบเพื่อแสดงความคิดเห็น ตอบกลับ และกดถูกใจ

}

ความคิดเห็น

{ if (values[0]) setSort(values[0]); }} variant="outline" aria-label="เรียงความคิดเห็น"> ล่าสุดยอดนิยม
{feed.error && {feed.error}} {feed.page.items.filter((item) => item.id !== linkedThread).map((item) => feed.refresh({ silent: true })} revision={feed.revision} />)} {!feed.page.items.length && !feed.busy && !feed.error && ยังไม่มีความคิดเห็นเป็นคนแรกที่ร่วมพูดคุยเกี่ยวกับไกด์นี้} {feed.busy && } {feed.page.nextCursor && } {linkedThread &&

การสนทนา

feed.refresh({ silent: true })} />
}
; }