diff --git a/app/admin/comments/page.tsx b/app/admin/comments/page.tsx index a5751ce..61495dd 100644 --- a/app/admin/comments/page.tsx +++ b/app/admin/comments/page.tsx @@ -11,7 +11,7 @@ export default async function AdminCommentsPage({ searchParams }: { searchParams const query = await searchParams; const initialTarget = query.target; const initialComment = initialTarget && query.comment && /^[0-9a-f-]{36}$/i.test(query.comment) ? query.comment : undefined; - const [initial, targets] = await Promise.all([listComments({ viewer, inbox: true, target: initialTarget }), listCommentTargets()]); + const [initial, targets] = await Promise.all([listComments({ viewer, inbox: true, grouped: true, target: initialTarget }), listCommentTargets()]); return <>

ความคิดเห็น

ตอบกลับและจัดการความคิดเห็นจากทุกไกด์

diff --git a/app/api/admin/comments/route.ts b/app/api/admin/comments/route.ts index b8f5384..b014afd 100644 --- a/app/api/admin/comments/route.ts +++ b/app/api/admin/comments/route.ts @@ -6,7 +6,7 @@ export async function GET(request: Request) { const viewer = await requireCommentViewer(); requireCommentAdmin(viewer); const query = new URL(request.url).searchParams; - return Response.json(await listComments({ viewer, inbox: true, target: query.get("target") || undefined, + return Response.json(await listComments({ viewer, inbox: true, grouped: query.get("grouped") === "true", target: query.get("target") || undefined, status: query.get("status") || undefined, unanswered: query.get("unanswered") === "true", cursor: query.get("cursor") }), { headers: { "Cache-Control": "private, no-store" } }); } catch (cause) { return errorResponse(cause); } diff --git a/app/api/comments/[id]/route.ts b/app/api/comments/[id]/route.ts index 534403a..21ea4aa 100644 --- a/app/api/comments/[id]/route.ts +++ b/app/api/comments/[id]/route.ts @@ -1,3 +1,5 @@ +import { after } from "next/server"; +import { sendCommentPush } from "@/lib/comments/push"; import { authorizeComment, commentId, getCommentViewer, listComments, mutateComment, requireCommentViewer } from "@/lib/comments/repository"; import { publishComment } from "@/lib/comments/publish"; import { errorResponse, requireSameOrigin } from "@/lib/security/http"; @@ -18,7 +20,9 @@ export async function PATCH(request: Request, context: Context) { requireSameOrigin(request); const viewer = await requireCommentViewer(); await limitRequest("comment-publish", viewer.id, 20); - return Response.json(await publishComment(request, viewer, { id: commentId((await context.params).id) })); + const result = await publishComment(request, viewer, { id: commentId((await context.params).id) }); + after(async () => { await sendCommentPush(result.id, result.version).catch(() => console.error("Comment notification failed")); }); + return Response.json(result); } catch (cause) { return errorResponse(cause); } } export async function DELETE(request: Request, context: Context) { diff --git a/app/api/comments/route.ts b/app/api/comments/route.ts index 2ded514..46096d2 100644 --- a/app/api/comments/route.ts +++ b/app/api/comments/route.ts @@ -21,7 +21,7 @@ export async function POST(request: Request) { const target = new URL(request.url).searchParams.get("target"); if (!target) throw new HttpError(400, "target-required"); const result = await publishComment(request, viewer, { target }); - after(async () => { await sendCommentPush(result.id).catch(() => console.error("Comment notification failed")); }); + after(async () => { await sendCommentPush(result.id, result.version).catch(() => console.error("Comment notification failed")); }); return Response.json(result, { status: 201 }); } catch (cause) { return errorResponse(cause); } } diff --git a/components/admin/admin-header.tsx b/components/admin/admin-header.tsx index ebb4d47..133455e 100644 --- a/components/admin/admin-header.tsx +++ b/components/admin/admin-header.tsx @@ -13,7 +13,6 @@ import { SwordsIcon, } from "lucide-react"; -import { AdminUnreadCount } from "@/components/comments/admin-unread-comments"; import { Button } from "@/components/ui/button"; import { PublicAccountMenu } from "@/components/public/public-account-menu"; import { NotificationBell } from "@/components/notifications/notification-bell"; @@ -35,7 +34,7 @@ export function AdminHeader() {