feat(comments): paginate life post and entity discussion comments

Implement cursor-based pagination for Life and Entity comments
Optimize Life Post queries to return comment counts and previews
Add "Load more" functionality to frontend discussion panels
This commit is contained in:
2026-05-03 15:20:05 +08:00
parent 0c76d6bfc8
commit 960898c858
8 changed files with 488 additions and 45 deletions

View File

@@ -72,6 +72,7 @@ import {
listDailyChecklistItems,
listHabitats,
listItems,
listLifeComments,
listLanguages,
listLifePosts,
listPokemon,
@@ -793,6 +794,12 @@ app.get('/api/life-posts', async (request) => {
return listLifePosts(request.query as Record<string, string | string[] | undefined>, user?.id ?? null, requestLocale(request));
});
app.get('/api/life-posts/:postId/comments', async (request, reply) => {
const { postId } = request.params as { postId: string };
const comments = await listLifeComments(Number(postId), request.query as Record<string, string | string[] | undefined>);
return comments ? comments : notFound(reply, request);
});
app.post('/api/life-posts', async (request, reply) => {
const user = await requirePermissionWithRateLimits(request, reply, 'life.posts.create', 'communityWrite');
return user
@@ -898,7 +905,11 @@ app.delete('/api/life-comments/:id', async (request, reply) => {
app.get('/api/discussions/:entityType/:entityId/comments', async (request, reply) => {
const { entityType, entityId } = request.params as { entityType: string; entityId: string };
const comments = await listEntityDiscussionComments(entityType, Number(entityId));
const comments = await listEntityDiscussionComments(
entityType,
Number(entityId),
request.query as Record<string, string | string[] | undefined>
);
return comments ? comments : notFound(reply, request);
});