feat(comments) : add newest and oldest sorting to admin inbox

This commit is contained in:
2026-10-13 00:48:43 +07:00 Unverified
parent d1dff1a763
commit 7933c08068
8 changed files with 98 additions and 7 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ export async function listComments(options: {
where reply.root_id = ${comments.id} and author.role = 'admin' and author.email_verified and not reply.hidden and reply.deleted_at is null)`);
const cursor = decodeCursor(options.cursor ?? null);
const top = !options.inbox && !options.rootId && options.sort === "top";
const ascending = Boolean(options.rootId);
const ascending = Boolean(options.rootId || (options.inbox && options.sort === "oldest"));
const timeBefore = cursor ? sql`(${comments.createdAt}, ${comments.id}) < (${cursor.time}::timestamptz, ${cursor.id}::uuid)` : undefined;
if (cursor) conditions.push(top
? or(sql`${likes} < ${cursor.likes}`, and(sql`${likes} = ${cursor.likes}`, timeBefore))!