From e1bac9fd3edaef5e42b0f4425f92205148892d80 Mon Sep 17 00:00:00 2001 From: Hikari Date: Thu, 19 Feb 2026 19:11:51 -0800 Subject: [PATCH] feat: integrate CommentDisplayComponent into all remaining media components Completed the integration of the shared CommentDisplayComponent across all media list views. Updated Components: - books-list.component.ts - music-list.component.ts - art-gallery.component.ts - shows-list.component.ts - manga-list.component.ts All components now: - Use the centralized CommentDisplayComponent for consistent UI - Support comment reporting via the Report button - Display pending review messages for reported comments - Handle comment editing through the shared component This completes the frontend integration for comment reporting across all media types! --- .../components/art/art-gallery.component.ts | 75 ++++++------------- .../components/books/books-list.component.ts | 71 ++++++------------ .../components/manga/manga-list.component.ts | 75 ++++++------------- .../components/music/music-list.component.ts | 75 ++++++------------- .../components/shows/shows-list.component.ts | 75 ++++++------------- 5 files changed, 120 insertions(+), 251 deletions(-) diff --git a/apps/frontend/src/app/components/art/art-gallery.component.ts b/apps/frontend/src/app/components/art/art-gallery.component.ts index 3ce88d0..fbaefe0 100644 --- a/apps/frontend/src/app/components/art/art-gallery.component.ts +++ b/apps/frontend/src/app/components/art/art-gallery.component.ts @@ -14,12 +14,13 @@ import { SanitizeService } from '../../services/sanitize.service'; import { SuggestionService } from '../../services/suggestion.service'; import { PaginationComponent } from '../shared/pagination.component'; import { LikeButtonComponent } from '../shared/like-button.component'; +import { CommentDisplayComponent } from '../comment-display/comment-display.component'; import { Art, CreateArtDto, UpdateArtDto, Comment, SuggestionEntity, Link } from '@library/shared-types'; @Component({ selector: 'app-art-gallery', standalone: true, - imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent], + imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent, CommentDisplayComponent], template: `
@@ -468,56 +469,11 @@ import { Art, CreateArtDto, UpdateArtDto, Comment, SuggestionEntity, Link } from } } - @if (commentsLoading()[art.id]) { -
Loading comments...
- } @else { - @for (comment of comments()[art.id] || []; track comment.id) { -
-
- @if (comment.user.avatar) { - - } - {{ comment.user.username }} - @if (comment.user.inDiscord) { - Discord - } - @if (comment.user.isVip) { - VIP - } - @if (comment.user.isMod) { - Mod - } - @if (comment.user.isStaff) { - Staff - } - {{ formatDate(comment.createdAt) }} - @if (canEditComment(comment)) { - - } - @if (canDeleteComment(comment)) { - - } -
- @if (editingCommentId() === comment.id) { -
- -
- - -
-
- } @else { -
- } -
- } @empty { -
No comments yet. Be the first to comment!
- } - } +
}
@@ -1615,4 +1571,21 @@ export class ArtGalleryComponent implements OnInit { toggleFilters() { this.showFilters.update(v => !v); } + + handleCommentEdit(artId: string, event: { commentId: string; content: string }) { + this.commentsService.updateCommentOnArt(artId, event.commentId, event.content).subscribe({ + next: (updatedComment) => { + this.comments.set({ + ...this.comments(), + [artId]: (this.comments()[artId] || []).map(c => + c.id === event.commentId ? updatedComment : c + ) + }); + } + }); + } + + getCommentsSignal(artId: string) { + return signal(this.comments()[artId] || []); + } } diff --git a/apps/frontend/src/app/components/books/books-list.component.ts b/apps/frontend/src/app/components/books/books-list.component.ts index 3bfaa06..0af45ac 100644 --- a/apps/frontend/src/app/components/books/books-list.component.ts +++ b/apps/frontend/src/app/components/books/books-list.component.ts @@ -14,12 +14,13 @@ import { SanitizeService } from '../../services/sanitize.service'; import { SuggestionService } from '../../services/suggestion.service'; import { PaginationComponent } from '../shared/pagination.component'; import { LikeButtonComponent } from '../shared/like-button.component'; +import { CommentDisplayComponent } from '../comment-display/comment-display.component'; import { Book, BookStatus, CreateBookDto, UpdateBookDto, Comment, SuggestionEntity, Link } from '@library/shared-types'; @Component({ selector: 'app-books-list', standalone: true, - imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent], + imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent, CommentDisplayComponent], template: `
@@ -655,52 +656,11 @@ import { Book, BookStatus, CreateBookDto, UpdateBookDto, Comment, SuggestionEnti @if (commentsLoading()[book.id]) {
Loading comments...
} @else { - @for (comment of comments()[book.id] || []; track comment.id) { -
-
- @if (comment.user.avatar) { - - } - {{ comment.user.username }} - @if (comment.user.inDiscord) { - Discord - } - @if (comment.user.isVip) { - VIP - } - @if (comment.user.isMod) { - Mod - } - @if (comment.user.isStaff) { - Staff - } - {{ formatDate(comment.createdAt) }} - @if (canEditComment(comment)) { - - } - @if (canDeleteComment(comment)) { - - } -
- @if (editingCommentId() === comment.id) { -
- -
- - -
-
- } @else { -
- } -
- } @empty { -
No comments yet. Be the first to comment!
- } + }
} @@ -1982,4 +1942,21 @@ export class BooksListComponent implements OnInit { alert('Failed to submit suggestion. Please try again.'); } } + + handleCommentEdit(bookId: string, event: { commentId: string; content: string }) { + this.commentsService.updateCommentOnBook(bookId, event.commentId, event.content).subscribe({ + next: (updatedComment) => { + this.comments.set({ + ...this.comments(), + [bookId]: (this.comments()[bookId] || []).map(c => + c.id === event.commentId ? updatedComment : c + ) + }); + } + }); + } + + getCommentsSignal(bookId: string) { + return signal(this.comments()[bookId] || []); + } } \ No newline at end of file diff --git a/apps/frontend/src/app/components/manga/manga-list.component.ts b/apps/frontend/src/app/components/manga/manga-list.component.ts index 4030f30..58c9ecf 100644 --- a/apps/frontend/src/app/components/manga/manga-list.component.ts +++ b/apps/frontend/src/app/components/manga/manga-list.component.ts @@ -14,12 +14,13 @@ import { SanitizeService } from '../../services/sanitize.service'; import { SuggestionService } from '../../services/suggestion.service'; import { PaginationComponent } from '../shared/pagination.component'; import { LikeButtonComponent } from '../shared/like-button.component'; +import { CommentDisplayComponent } from '../comment-display/comment-display.component'; import { Manga, MangaStatus, CreateMangaDto, UpdateMangaDto, Comment, SuggestionEntity, Link } from '@library/shared-types'; @Component({ selector: 'app-manga-list', standalone: true, - imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent], + imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent, CommentDisplayComponent], template: `
@@ -610,56 +611,11 @@ import { Manga, MangaStatus, CreateMangaDto, UpdateMangaDto, Comment, Suggestion } } - @if (commentsLoading()[manga.id]) { -
Loading comments...
- } @else { - @for (comment of comments()[manga.id] || []; track comment.id) { -
-
- @if (comment.user.avatar) { - - } - {{ comment.user.username }} - @if (comment.user.inDiscord) { - Discord - } - @if (comment.user.isVip) { - VIP - } - @if (comment.user.isMod) { - Mod - } - @if (comment.user.isStaff) { - Staff - } - {{ formatDate(comment.createdAt) }} - @if (canEditComment(comment)) { - - } - @if (canDeleteComment(comment)) { - - } -
- @if (editingCommentId() === comment.id) { -
- -
- - -
-
- } @else { -
- } -
- } @empty { -
No comments yet. Be the first to comment!
- } - } +
}
@@ -1780,4 +1736,21 @@ export class MangaListComponent implements OnInit { alert('Failed to submit suggestion. Please try again.'); } } + + handleCommentEdit(mangaId: string, event: { commentId: string; content: string }) { + this.commentsService.updateCommentOnManga(mangaId, event.commentId, event.content).subscribe({ + next: (updatedComment) => { + this.comments.set({ + ...this.comments(), + [mangaId]: (this.comments()[mangaId] || []).map(c => + c.id === event.commentId ? updatedComment : c + ) + }); + } + }); + } + + getCommentsSignal(mangaId: string) { + return signal(this.comments()[mangaId] || []); + } } diff --git a/apps/frontend/src/app/components/music/music-list.component.ts b/apps/frontend/src/app/components/music/music-list.component.ts index a5ceeeb..1c91be4 100644 --- a/apps/frontend/src/app/components/music/music-list.component.ts +++ b/apps/frontend/src/app/components/music/music-list.component.ts @@ -14,12 +14,13 @@ import { SanitizeService } from '../../services/sanitize.service'; import { SuggestionService } from '../../services/suggestion.service'; import { PaginationComponent } from '../shared/pagination.component'; import { LikeButtonComponent } from '../shared/like-button.component'; +import { CommentDisplayComponent } from '../comment-display/comment-display.component'; import { Music, MusicStatus, MusicType, CreateMusicDto, UpdateMusicDto, Comment, SuggestionEntity, Link } from '@library/shared-types'; @Component({ selector: 'app-music-list', standalone: true, - imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent], + imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent, CommentDisplayComponent], template: `
@@ -686,56 +687,11 @@ import { Music, MusicStatus, MusicType, CreateMusicDto, UpdateMusicDto, Comment, } } - @if (commentsLoading()[music.id]) { -
Loading comments...
- } @else { - @for (comment of comments()[music.id] || []; track comment.id) { -
-
- @if (comment.user.avatar) { - - } - {{ comment.user.username }} - @if (comment.user.inDiscord) { - Discord - } - @if (comment.user.isVip) { - VIP - } - @if (comment.user.isMod) { - Mod - } - @if (comment.user.isStaff) { - Staff - } - {{ formatDate(comment.createdAt) }} - @if (canEditComment(comment)) { - - } - @if (canDeleteComment(comment)) { - - } -
- @if (editingCommentId() === comment.id) { -
- -
- - -
-
- } @else { -
- } -
- } @empty { -
No comments yet. Be the first to comment!
- } - } +
}
@@ -2014,4 +1970,21 @@ export class MusicListComponent implements OnInit { alert('Failed to submit suggestion. Please try again.'); } } + + handleCommentEdit(musicId: string, event: { commentId: string; content: string }) { + this.commentsService.updateCommentOnMusic(musicId, event.commentId, event.content).subscribe({ + next: (updatedComment) => { + this.comments.set({ + ...this.comments(), + [musicId]: (this.comments()[musicId] || []).map(c => + c.id === event.commentId ? updatedComment : c + ) + }); + } + }); + } + + getCommentsSignal(musicId: string) { + return signal(this.comments()[musicId] || []); + } } \ No newline at end of file diff --git a/apps/frontend/src/app/components/shows/shows-list.component.ts b/apps/frontend/src/app/components/shows/shows-list.component.ts index 1f6268e..ce41b07 100644 --- a/apps/frontend/src/app/components/shows/shows-list.component.ts +++ b/apps/frontend/src/app/components/shows/shows-list.component.ts @@ -14,12 +14,13 @@ import { SanitizeService } from '../../services/sanitize.service'; import { SuggestionService } from '../../services/suggestion.service'; import { PaginationComponent } from '../shared/pagination.component'; import { LikeButtonComponent } from '../shared/like-button.component'; +import { CommentDisplayComponent } from '../comment-display/comment-display.component'; import { Show, ShowStatus, ShowType, CreateShowDto, UpdateShowDto, Comment, SuggestionEntity, Link } from '@library/shared-types'; @Component({ selector: 'app-shows-list', standalone: true, - imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent], + imports: [CommonModule, FormsModule, PaginationComponent, LikeButtonComponent, CommentDisplayComponent], template: `
@@ -604,56 +605,11 @@ import { Show, ShowStatus, ShowType, CreateShowDto, UpdateShowDto, Comment, Sugg } } - @if (commentsLoading()[show.id]) { -
Loading comments...
- } @else { - @for (comment of comments()[show.id] || []; track comment.id) { -
-
- @if (comment.user.avatar) { - - } - {{ comment.user.username }} - @if (comment.user.inDiscord) { - Discord - } - @if (comment.user.isVip) { - VIP - } - @if (comment.user.isMod) { - Mod - } - @if (comment.user.isStaff) { - Staff - } - {{ formatDate(comment.createdAt) }} - @if (canEditComment(comment)) { - - } - @if (canDeleteComment(comment)) { - - } -
- @if (editingCommentId() === comment.id) { -
- -
- - -
-
- } @else { -
- } -
- } @empty { -
No comments yet. Be the first to comment!
- } - } +
}
@@ -1783,4 +1739,21 @@ export class ShowsListComponent implements OnInit { alert('Failed to submit suggestion. Please try again.'); } } + + handleCommentEdit(showId: string, event: { commentId: string; content: string }) { + this.commentsService.updateCommentOnShow(showId, event.commentId, event.content).subscribe({ + next: (updatedComment) => { + this.comments.set({ + ...this.comments(), + [showId]: (this.comments()[showId] || []).map(c => + c.id === event.commentId ? updatedComment : c + ) + }); + } + }); + } + + getCommentsSignal(showId: string) { + return signal(this.comments()[showId] || []); + } }