diff --git a/AGENTS.md b/AGENTS.md index b090747..07eb65d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,9 +2,9 @@ # This is NOT the Next.js you know -This version has breaking changes - APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices. +This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices. -This block is written and re-added by `next dev` - verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean. +This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean. diff --git a/components/comments/admin-comment-inbox.tsx b/components/comments/admin-comment-inbox.tsx index 457eca9..d8424dc 100644 --- a/components/comments/admin-comment-inbox.tsx +++ b/components/comments/admin-comment-inbox.tsx @@ -32,8 +32,8 @@ export function AdminCommentInbox({ initial, targets, initialTarget, initialComm const markRead = useMarkCommentsRead(); useEffect(() => { void markRead(target?.value ?? "all"); }, [markRead, target, feed.revision]); return
- {initialComment && initialTarget && - การสนทนาความคิดเห็นจากการแจ้งเตือนและคำตอบกลับ + {initialComment && initialTarget && + การสนทนาความคิดเห็นจากการแจ้งเตือนและคำตอบกลับ {notificationOpen && feed.refresh({ silent: true })} />} } diff --git a/components/comments/comment-card.tsx b/components/comments/comment-card.tsx index 7ec5e31..09c43a5 100644 --- a/components/comments/comment-card.tsx +++ b/components/comments/comment-card.tsx @@ -121,6 +121,8 @@ export function CommentCard({ item, viewer, onChange, revision = 0, inbox = fals item: CommentItem; viewer: CommentViewer | null; onChange: () => void | Promise; revision?: number; inbox?: boolean; moderationDetails?: boolean; replies?: boolean; defaultExpanded?: boolean; focusReplyId?: string; highlighted?: boolean; }) { const router = useRouter(); + const fullWidthMobile = inbox || moderationDetails; + const isMobileInbox = () => inbox && window.matchMedia("(max-width: 639px)").matches; const [mode, setMode] = useState<"reply" | "edit" | null>(null); const [expanded, setExpanded] = useState(defaultExpanded); const [hasOpenedReplies, setHasOpenedReplies] = useState(defaultExpanded); @@ -202,14 +204,24 @@ export function CommentCard({ item, viewer, onChange, revision = 0, inbox = fals } function compose(next: "reply" | "edit") { if (!viewer) return router.push(commentSignInHref()); + if (next === "reply" && isMobileInbox()) { setThread(true); return; } setMode(next); } const canReadHistory = (!item.deleted && !item.hidden) || Boolean(viewer?.admin); - return
-
+ return
{ + if (isMobileInbox() && event.currentTarget.contains(event.target as Node) && !(event.target as Element).closest("a, button, input, textarea, [role='button']")) setThread(true); + }} id={`comment-${item.id}`} tabIndex={highlighted ? -1 : undefined} className={cn("flex scroll-mt-36 flex-col gap-2 py-2", inbox && "border-b pb-5", highlighted && "rounded-lg bg-accent ring-2 ring-ring", expanded && !item.rootId && "relative before:absolute before:bottom-8 before:left-5 before:top-12 before:border-l before:border-border", fullWidthMobile && "max-sm:before:hidden")}> + {inbox && + {item.targetImage && <> + {/* eslint-disable-next-line @next/next/no-img-element */} + {`ภาพ + } + {item.target.startsWith("stygian:") && {item.targetName}} + } +
{item.authorName.slice(0, 2)} -
-
{item.authorName}{item.authorAdmin && ผู้ดูแล} +
+
{item.authorName}{item.authorAdmin && ผู้ดูแล} {inbox && item.rootId && ตอบกลับ} {(inbox || moderationDetails) && item.hidden && {item.ownHidden ? "ซ่อนอยู่" : "การสนทนาถูกซ่อน"}} @@ -224,6 +236,7 @@ export function CommentCard({ item, viewer, onChange, revision = 0, inbox = fals }
+
{item.replyToName &&

ตอบกลับ {item.replyToName}

} {(item.deleted || item.hidden) && !viewer?.admin ?

{item.deleted ? "ความคิดเห็นถูกลบแล้ว" : "ความคิดเห็นถูกซ่อนโดยผู้ดูแล"}

: } @@ -236,11 +249,11 @@ export function CommentCard({ item, viewer, onChange, revision = 0, inbox = fals {viewer?.admin ? : optimistic.hearted && !item.deleted && !item.hidden && ผู้ดูแลถูกใจ} - {inbox && !replies && item.hasReplies && } + {inbox && }
{mode && setMode(null)} onSaved={() => { setMode(null); expandReplies(true); onChange(); }} />} - {replies && !item.rootId && (item.replyCount > 0 || expanded) && expandReplies(value.includes("replies"))}> + {replies && !item.rootId && (item.replyCount > 0 || expanded) && { if (isMobileInbox()) setThread(true); else expandReplies(value.includes("replies")); }}> {`การตอบกลับ ${item.replyCount.toLocaleString("th-TH")} รายการ`} {hasOpenedReplies &&
@@ -250,23 +263,17 @@ export function CommentCard({ item, viewer, onChange, revision = 0, inbox = fals
}
} +
- {inbox && - {item.targetImage && <> - {/* eslint-disable-next-line @next/next/no-img-element */} - {`ภาพ - } - {item.target.startsWith("stygian:") && {item.targetName}} - }
ประวัติการแก้ไขดูข้อความและรูปภาพในแต่ละเวอร์ชันของความคิดเห็น {history && } ลบความคิดเห็นนี้?ความคิดเห็นนี้ คำตอบกลับทุกระดับ ประวัติการแก้ไข และรูปภาพจะถูกลบอย่างถาวร ไม่สามารถกู้คืนได้
- - การสนทนาความคิดเห็นต้นทางและคำตอบกลับ เรียงจากเก่าไปใหม่ - {thread && } + + การสนทนาความคิดเห็นต้นทางและคำตอบกลับ เรียงจากเก่าไปใหม่ + {thread && }
; } @@ -312,11 +319,12 @@ function CommentReplyTree({ items, viewer, onChange, focusReplyId, moderationDet return siblings.map((reply, index) =>
-
+
- {groups.has(reply.id) &&
+ {groups.has(reply.id) &&
{branch(reply.id)}
}
); @@ -347,7 +355,7 @@ export function CommentThread({ rootId, expectedTarget, onChange, focusReplyId } }, [load]); return
{error && {error}} - {data && { await load(true); await onChange(); }} />} + {data && { await load(true); await onChange(); }} />} {!data && !error && } {error && }
;