From 25a9f37ded956460fdf5877db2bb88f8fc2238ad Mon Sep 17 00:00:00 2001 From: RF9A5V Date: Wed, 2 Apr 2025 07:29:22 -0700 Subject: [PATCH] Add Comment Count to Video Preview Components (#6635) * WIP: Add backend functionality to store comment count per video and update on comment visibility actions * WIP: Display image icon and comment count on video miniature component * Probably don't need to index the comment count * Added comment count back to mini video component * Added basic tests * Sort by comments, more robust comments count --------- Co-authored-by: Chocobozzz --- .../my-videos/my-videos.component.html | 19 +++-- .../my-videos/my-videos.component.ts | 3 +- .../shared/shared-main/video/video.model.ts | 4 ++ .../video-miniature.component.ts | 4 +- packages/models/src/videos/video.model.ts | 2 + .../src/api/moderation/comment-approval.ts | 69 ++++++++++++++++++- .../tests/src/api/videos/video-comments.ts | 38 ++++++++-- server/core/initializers/constants.ts | 53 +++++++------- .../migrations/0880-video-comment-count.ts | 31 +++++++++ .../video/formatter/video-api-format.ts | 2 + .../video/shared/video-table-attributes.ts | 7 +- server/core/models/video/video-comment.ts | 68 +++++++++++++++--- server/core/models/video/video.ts | 7 ++ support/doc/api/openapi.yaml | 4 ++ 14 files changed, 255 insertions(+), 56 deletions(-) create mode 100644 server/core/initializers/migrations/0880-video-comment-count.ts diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.html index 77906c008..a6ee6ef13 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.html +++ b/client/src/app/+my-library/my-videos/my-videos.component.html @@ -78,14 +78,15 @@ - {{ getColumn('duration').label }} - {{ getColumn('name').label }} - {{ getColumn('privacy').label }} - {{ getColumn('sensitive').label }} - {{ getColumn('playlists').label }} - {{ getColumn('insights').label }} + {{ getColumn('duration').label }} + {{ getColumn('name').label }} + {{ getColumn('privacy').label }} + {{ getColumn('sensitive').label }} + {{ getColumn('playlists').label }} + {{ getColumn('insights').label }} + {{ getColumn('comments').label }} {{ getColumn('published').label }} - {{ getColumn('state').label }} + {{ getColumn('state').label }}
@@ -162,6 +163,10 @@ + + {video.comments, plural, =0 {No comments} =1 {1 comment} other {{{ video.comments | myNumberFormatter }} comments}} + + {{ video.publishedAt | ptDate: 'short' }} diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index c680e249a..73e28830c 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts @@ -52,7 +52,7 @@ import { VideoPrivacyBadgeComponent } from '../../shared/shared-video/video-priv import { VideoStateBadgeComponent } from '../../shared/shared-video/video-state-badge.component' import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' -type Column = 'duration' | 'name' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state' +type Column = 'duration' | 'name' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state' | 'comments' type CommonFilter = 'live' | 'vod' | 'private' | 'internal' | 'unlisted' | 'password-protected' | 'public' @Component({ @@ -157,6 +157,7 @@ export class MyVideosComponent extends RestTable