Add author indicator to the comment replies loader

pull/2367/head
Rigel Kent 2019-12-28 11:27:31 +01:00
parent bf64ed4196
commit 5b0413ddaa
No known key found for this signature in database
GPG Key ID: 5E53E96A494E452F
6 changed files with 30 additions and 3 deletions

View File

@ -15,6 +15,7 @@ export class VideoComment implements VideoCommentServerModel {
deletedAt: Date | string deletedAt: Date | string
isDeleted: boolean isDeleted: boolean
account: AccountInterface account: AccountInterface
totalRepliesFromVideoAuthor: number
totalReplies: number totalReplies: number
by: string by: string
accountAvatarUrl: string accountAvatarUrl: string
@ -33,6 +34,7 @@ export class VideoComment implements VideoCommentServerModel {
this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
this.isDeleted = hash.isDeleted this.isDeleted = hash.isDeleted
this.account = hash.account this.account = hash.account
this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
this.totalReplies = hash.totalReplies this.totalReplies = hash.totalReplies
if (this.account) { if (this.account) {

View File

@ -69,9 +69,19 @@
></my-video-comment> ></my-video-comment>
<div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment.id)" class="view-replies"> <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> <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> <my-small-loader class="comment-thread-loading" [loading]="threadLoading[comment.id]"></my-small-loader>
</div> </div>
</div> </div>

View File

@ -14,7 +14,7 @@
} }
.glyphicon, .comment-thread-loading { .glyphicon, .comment-thread-loading {
margin-left: 5px; margin-right: 5px;
display: inline-block; display: inline-block;
font-size: 13px; font-size: 13px;
} }

View File

@ -56,6 +56,17 @@ enum ScopeNames {
')' ')'
), ),
'totalReplies' '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, updatedAt: this.updatedAt,
deletedAt: this.deletedAt, deletedAt: this.deletedAt,
isDeleted: this.isDeleted(), isDeleted: this.isDeleted(),
totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0,
totalReplies: this.get('totalReplies') || 0, totalReplies: this.get('totalReplies') || 0,
account: this.Account ? this.Account.toFormattedJSON() : null account: this.Account ? this.Account.toFormattedJSON() : null
} as VideoComment } as VideoComment

View File

@ -11,6 +11,7 @@ export interface VideoComment {
updatedAt: Date | string updatedAt: Date | string
deletedAt: Date | string deletedAt: Date | string
isDeleted: boolean isDeleted: boolean
totalRepliesFromVideoAuthor: number
totalReplies: number totalReplies: number
account: Account account: Account
} }

View File

@ -2257,6 +2257,8 @@ components:
type: string type: string
updatedAt: updatedAt:
type: string type: string
totalRepliesFromVideoAuthor:
type: number
totalReplies: totalReplies:
type: number type: number
account: account: