aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2019-12-28 11:27:31 +0100
committerRigel Kent <sendmemail@rigelk.eu>2019-12-28 11:48:53 +0100
commit5b0413ddaa7949a6a44512a8281c5a23466599ae (patch)
tree07dafe7f97ffc1e7570e8b1ee9515f29d6c2d611
parentbf64ed4196938ba9002c887cadb01bd2a6e3127a (diff)
downloadPeerTube-5b0413ddaa7949a6a44512a8281c5a23466599ae.tar.gz
PeerTube-5b0413ddaa7949a6a44512a8281c5a23466599ae.tar.zst
PeerTube-5b0413ddaa7949a6a44512a8281c5a23466599ae.zip
Add author indicator to the comment replies loader
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.model.ts2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.html14
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.scss2
-rw-r--r--server/models/video/video-comment.ts12
-rw-r--r--shared/models/videos/video-comment.model.ts1
-rw-r--r--support/doc/api/openapi.yaml2
6 files changed, 30 insertions, 3 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.model.ts b/client/src/app/videos/+video-watch/comment/video-comment.model.ts
index 719d1f04e..aaeb0ea9c 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.model.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.model.ts
@@ -15,6 +15,7 @@ export class VideoComment implements VideoCommentServerModel {
15 deletedAt: Date | string 15 deletedAt: Date | string
16 isDeleted: boolean 16 isDeleted: boolean
17 account: AccountInterface 17 account: AccountInterface
18 totalRepliesFromVideoAuthor: number
18 totalReplies: number 19 totalReplies: number
19 by: string 20 by: string
20 accountAvatarUrl: string 21 accountAvatarUrl: string
@@ -33,6 +34,7 @@ export class VideoComment implements VideoCommentServerModel {
33 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null 34 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
34 this.isDeleted = hash.isDeleted 35 this.isDeleted = hash.isDeleted
35 this.account = hash.account 36 this.account = hash.account
37 this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
36 this.totalReplies = hash.totalReplies 38 this.totalReplies = hash.totalReplies
37 39
38 if (this.account) { 40 if (this.account) {
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.html b/client/src/app/videos/+video-watch/comment/video-comments.component.html
index e284eab0a..8f5c583d3 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.html
@@ -69,9 +69,19 @@
69 ></my-video-comment> 69 ></my-video-comment>
70 70
71 <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment.id)" class="view-replies"> 71 <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment.id)" class="view-replies">
72 <ng-container i18n>View all {{ comment.totalReplies }} replies</ng-container>
73
74 <span *ngIf="!threadLoading[comment.id]" class="glyphicon glyphicon-menu-down"></span> 72 <span *ngIf="!threadLoading[comment.id]" class="glyphicon glyphicon-menu-down"></span>
73
74 <ng-container *ngIf="comment.totalRepliesFromVideoAuthor > 0; then hasAuthorComments; else noAuthorComments"></ng-container>
75 <ng-template #hasAuthorComments>
76 <ng-container *ngIf="comment.totalReplies !== comment.totalRepliesFromVideoAuthor; else onlyAuthorComments" i18n>
77 View {{ comment.totalReplies }} replies from {{ video?.account?.displayName || 'the author' }} and others
78 </ng-container>
79 <ng-template i18n #onlyAuthorComments>
80 View {{ comment.totalReplies }} replies from {{ video?.account?.displayName || 'the author' }}
81 </ng-template>
82 </ng-template>
83 <ng-template i18n #noAuthorComments>View {{ comment.totalReplies }} replies</ng-template>
84
75 <my-small-loader class="comment-thread-loading" [loading]="threadLoading[comment.id]"></my-small-loader> 85 <my-small-loader class="comment-thread-loading" [loading]="threadLoading[comment.id]"></my-small-loader>
76 </div> 86 </div>
77 </div> 87 </div>
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.scss b/client/src/app/videos/+video-watch/comment/video-comments.component.scss
index c02f6c21b..600bc1cee 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.scss
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.scss
@@ -14,7 +14,7 @@
14} 14}
15 15
16.glyphicon, .comment-thread-loading { 16.glyphicon, .comment-thread-loading {
17 margin-left: 5px; 17 margin-right: 5px;
18 display: inline-block; 18 display: inline-block;
19 font-size: 13px; 19 font-size: 13px;
20} 20}
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 28f011b03..c2798e82a 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -56,6 +56,17 @@ enum ScopeNames {
56 ')' 56 ')'
57 ), 57 ),
58 'totalReplies' 58 'totalReplies'
59 ],
60 [
61 Sequelize.literal(
62 '(' +
63 'SELECT COUNT("replies"."id") ' +
64 'FROM "videoComment" AS "replies" ' +
65 'WHERE "replies"."originCommentId" = "VideoCommentModel"."id" ' +
66 'AND "accountId" = ' + userAccountId +
67 ')'
68 ),
69 'totalRepliesFromVideoAuthor'
59 ] 70 ]
60 ] 71 ]
61 } 72 }
@@ -501,6 +512,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
501 updatedAt: this.updatedAt, 512 updatedAt: this.updatedAt,
502 deletedAt: this.deletedAt, 513 deletedAt: this.deletedAt,
503 isDeleted: this.isDeleted(), 514 isDeleted: this.isDeleted(),
515 totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0,
504 totalReplies: this.get('totalReplies') || 0, 516 totalReplies: this.get('totalReplies') || 0,
505 account: this.Account ? this.Account.toFormattedJSON() : null 517 account: this.Account ? this.Account.toFormattedJSON() : null
506 } as VideoComment 518 } as VideoComment
diff --git a/shared/models/videos/video-comment.model.ts b/shared/models/videos/video-comment.model.ts
index 044962633..eec7dba1c 100644
--- a/shared/models/videos/video-comment.model.ts
+++ b/shared/models/videos/video-comment.model.ts
@@ -11,6 +11,7 @@ export interface VideoComment {
11 updatedAt: Date | string 11 updatedAt: Date | string
12 deletedAt: Date | string 12 deletedAt: Date | string
13 isDeleted: boolean 13 isDeleted: boolean
14 totalRepliesFromVideoAuthor: number
14 totalReplies: number 15 totalReplies: number
15 account: Account 16 account: Account
16} 17}
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index 5c5845f2b..a193bebab 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -2257,6 +2257,8 @@ components:
2257 type: string 2257 type: string
2258 updatedAt: 2258 updatedAt:
2259 type: string 2259 type: string
2260 totalRepliesFromVideoAuthor:
2261 type: number
2260 totalReplies: 2262 totalReplies:
2261 type: number 2263 type: number
2262 account: 2264 account: