Add author indicator to the comment replies loader
authorRigel Kent <sendmemail@rigelk.eu>
Sat, 28 Dec 2019 10:27:31 +0000 (11:27 +0100)
committerRigel Kent <sendmemail@rigelk.eu>
Sat, 28 Dec 2019 10:48:53 +0000 (11:48 +0100)
client/src/app/videos/+video-watch/comment/video-comment.model.ts
client/src/app/videos/+video-watch/comment/video-comments.component.html
client/src/app/videos/+video-watch/comment/video-comments.component.scss
server/models/video/video-comment.ts
shared/models/videos/video-comment.model.ts
support/doc/api/openapi.yaml

index 719d1f04e1cf6aefc0c36d2397a258f267c3237a..aaeb0ea9c282c39f31db21f586c70bbbae3387ce 100644 (file)
@@ -15,6 +15,7 @@ export class VideoComment implements VideoCommentServerModel {
   deletedAt: Date | string
   isDeleted: boolean
   account: AccountInterface
+  totalRepliesFromVideoAuthor: number
   totalReplies: number
   by: string
   accountAvatarUrl: string
@@ -33,6 +34,7 @@ export class VideoComment implements VideoCommentServerModel {
     this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
     this.isDeleted = hash.isDeleted
     this.account = hash.account
+    this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
     this.totalReplies = hash.totalReplies
 
     if (this.account) {
index e284eab0a1e3203bb30c78d9356217de1cc4d9e3..8f5c583d38ef1dbf2e9cbf0ae0f3b2f8f5f44af8 100644 (file)
         ></my-video-comment>
 
         <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment.id)" class="view-replies">
-          <ng-container i18n>View all {{ comment.totalReplies }} replies</ng-container>
-
           <span *ngIf="!threadLoading[comment.id]" class="glyphicon glyphicon-menu-down"></span>
+
+          <ng-container *ngIf="comment.totalRepliesFromVideoAuthor > 0; then hasAuthorComments; else noAuthorComments"></ng-container>
+          <ng-template #hasAuthorComments>
+            <ng-container *ngIf="comment.totalReplies !== comment.totalRepliesFromVideoAuthor; else onlyAuthorComments" i18n>
+              View {{ comment.totalReplies }} replies from {{ video?.account?.displayName || 'the author' }} and others
+            </ng-container>
+            <ng-template i18n #onlyAuthorComments>
+              View {{ comment.totalReplies }} replies from {{ video?.account?.displayName || 'the author' }}
+            </ng-template>
+          </ng-template>
+          <ng-template i18n #noAuthorComments>View {{ comment.totalReplies }} replies</ng-template>
+
           <my-small-loader class="comment-thread-loading" [loading]="threadLoading[comment.id]"></my-small-loader>
         </div>
       </div>
index c02f6c21bb71ba7e6c43c49ce7542132f1378d72..600bc1ceee4efc08018b47aa7626a8cc56ce704a 100644 (file)
@@ -14,7 +14,7 @@
 }
 
 .glyphicon, .comment-thread-loading {
-  margin-left: 5px;
+  margin-right: 5px;
   display: inline-block;
   font-size: 13px;
 }
index 28f011b03b3a1b13a6fc7b577d886f09b488098e..c2798e82aad49345973ce1a7e0dc0328ce73c618 100644 (file)
@@ -56,6 +56,17 @@ enum ScopeNames {
               ')'
             ),
             'totalReplies'
+          ],
+          [
+            Sequelize.literal(
+              '(' +
+                'SELECT COUNT("replies"."id") ' +
+                'FROM "videoComment" AS "replies" ' +
+                'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' +
+                'AND "accountId" = ' + userAccountId +
+              ')'
+            ),
+            'totalRepliesFromVideoAuthor'
           ]
         ]
       }
@@ -501,6 +512,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
       updatedAt: this.updatedAt,
       deletedAt: this.deletedAt,
       isDeleted: this.isDeleted(),
+      totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0,
       totalReplies: this.get('totalReplies') || 0,
       account: this.Account ? this.Account.toFormattedJSON() : null
     } as VideoComment
index 04496263324ae8f347b4752afa337a3b78ae86ba..eec7dba1cef7f92569476ff6ebd3d983eba35f63 100644 (file)
@@ -11,6 +11,7 @@ export interface VideoComment {
   updatedAt: Date | string
   deletedAt: Date | string
   isDeleted: boolean
+  totalRepliesFromVideoAuthor: number
   totalReplies: number
   account: Account
 }
index 5c5845f2b6a8aa1dc56f2f81c25fda3d86cab7db..a193bebab981ea5b66d2fa1ac660d16c764999f1 100644 (file)
@@ -2257,6 +2257,8 @@ components:
           type: string
         updatedAt:
           type: string
+        totalRepliesFromVideoAuthor:
+          type: number
         totalReplies:
           type: number
         account: