feat: add comment replies and liking functionality

- Introduced support for nested comment replies in both frontend and backend.
- Added comment liking and unliking features, including like count and "isLiked" state tracking.
- Updated database schema with `parentId` and new `comment_likes` table.
- Enhanced UI for threaded comments and implemented display of like counts and reply actions.
- Refactored APIs and repositories to support replies, likes, and enriched comment data.
This commit is contained in:
Mathis HERRIOT
2026-01-29 15:26:54 +01:00
parent ed3ed66cab
commit 0976850c0c
11 changed files with 405 additions and 92 deletions

View File

@@ -9,11 +9,11 @@ export class CommentsRepository {
constructor(private readonly databaseService: DatabaseService) {}
async create(data: NewCommentInDb) {
const [comment] = await this.databaseService.db
const results = await this.databaseService.db
.insert(comments)
.values(data)
.returning();
return comment;
return results[0];
}
async findAllByContentId(contentId: string) {
@@ -21,6 +21,7 @@ export class CommentsRepository {
.select({
id: comments.id,
text: comments.text,
parentId: comments.parentId,
createdAt: comments.createdAt,
updatedAt: comments.updatedAt,
user: {
@@ -37,11 +38,11 @@ export class CommentsRepository {
}
async findOne(id: string) {
const [comment] = await this.databaseService.db
const results = await this.databaseService.db
.select()
.from(comments)
.where(and(eq(comments.id, id), isNull(comments.deletedAt)));
return comment;
return results[0];
}
async delete(id: string) {