ActivityPub-federated video streaming platform using P2P directly in your web browser
Small refactor comments
kimsiblefdd129652135
diff --git a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.tsindex 3d0611a2df..3fa5fd623a 100644--- a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts+++ b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts@@ -17,11 +17,10 @@ import { I18n } from '@ngx-translate/i18n-polyfill'export class VideoCommentAddComponent extends FormReactive implements OnChanges, OnInit {@Input() user: User@Input() video: Video- @Input() parentComment: VideoComment- @Input() parentComments: VideoComment[]+ @Input() parentComment?: VideoComment+ @Input() parentComments?: VideoComment[]@Input() focusOnInit = false@Input() textValue?: string- @Input() commentThread?: boolean@Output() commentCreated = new EventEmitter<VideoComment>()@Output() cancel = new EventEmitter()@@ -57,27 +56,13 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,})if (this.user) {- if (this.commentThread) {+ if (!this.parentComment) {this.addingCommentButtonValue = this.i18n('Comment')} else {this.addingCommentButtonValue = this.i18n('Reply')}- if (this.textValue) {- this.patchTextValue(this.textValue, this.focusOnInit)- return- }-- if (this.parentComment) {- const mentions = this.parentComments- .filter(c => c.account && c.account.id !== this.user.account.id) // Don't add mention of ourselves- .map(c => '@' + c.by)-- const mentionsSet = new Set(mentions)- const mentionsText = Array.from(mentionsSet).join(' ') + ' '-- this.patchTextValue(mentionsText, this.focusOnInit)- }+ this.initTextValue()}}@@ -176,6 +161,24 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,.addCommentThread(this.video.id, commentCreate)}+ private initTextValue () {+ if (this.textValue) {+ this.patchTextValue(this.textValue, this.focusOnInit)+ return+ }++ if (this.parentComment) {+ const mentions = this.parentComments+ .filter(c => c.account && c.account.id !== this.user.account.id) // Don't add mention of ourselves+ .map(c => '@' + c.by)++ const mentionsSet = new Set(mentions)+ const mentionsText = Array.from(mentionsSet).join(' ') + ' '++ this.patchTextValue(mentionsText, this.focusOnInit)+ }+ }+private patchTextValue (text: string, focus: boolean) {setTimeout(() => {if (focus) {diff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.html b/client/src/app/+videos/+video-watch/comment/video-comment.component.htmlindex 8e44d00522..c4b2cd1179 100644--- a/client/src/app/+videos/+video-watch/comment/video-comment.component.html+++ b/client/src/app/+videos/+video-watch/comment/video-comment.component.html@@ -1,4 +1,4 @@-<div *ngIf="!comment.isDeleted || comment.isDeleted && comment.totalReplies !== 0" class="root-comment">+<div *ngIf="isNotDeletedOrDeletedWithReplies()" class="root-comment"><div class="left"><a *ngIf="!comment.isDeleted" [href]="comment.account.url" target="_blank" rel="noopener noreferrer"><imgdiff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts b/client/src/app/+videos/+video-watch/comment/video-comment.component.tsindex 5491023ee5..17e7e28ca4 100644--- a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts+++ b/client/src/app/+videos/+video-watch/comment/video-comment.component.ts@@ -75,7 +75,7 @@ export class VideoCommentComponent implements OnInit, OnChanges {this.resetReply.emit()- delete this.redraftValue+ this.redraftValue = undefined}onWantToReply (comment?: VideoComment) {@@ -133,6 +133,10 @@ export class VideoCommentComponent implements OnInit, OnChanges {($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()}+ isNotDeletedOrDeletedWithReplies () {+ return !this.comment.isDeleted || this.comment.isDeleted && this.comment.totalReplies !== 0+ }+private getUserIfNeeded (account: Account) {if (!account.userId) returnif (!this.authService.isLoggedIn()) returndiff --git a/client/src/app/+videos/+video-watch/comment/video-comments.component.html b/client/src/app/+videos/+video-watch/comment/video-comments.component.htmlindex ac69f094b1..1bc0885a4d 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@@ -28,7 +28,6 @@[user]="user"(commentCreated)="onCommentThreadCreated($event)"[textValue]="commentThreadRedraftValue"- [commentThread]="true"></my-video-comment-add><div *ngIf="componentPagination.totalItems === 0 && comments.length === 0" i18n>No comments.</div>diff --git a/client/src/app/+videos/+video-watch/comment/video-comments.component.ts b/client/src/app/+videos/+video-watch/comment/video-comments.component.tsindex 9e8e143c25..adce31c5bb 100644--- a/client/src/app/+videos/+video-watch/comment/video-comments.component.ts+++ b/client/src/app/+videos/+video-watch/comment/video-comments.component.ts@@ -133,7 +133,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {onCommentThreadCreated (comment: VideoComment) {this.comments.unshift(comment)- delete this.commentThreadRedraftValue+ this.commentThreadRedraftValue = undefined}onWantedToReply (comment: VideoComment) {@@ -142,7 +142,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {onResetReply () {this.inReplyToCommentId = undefined- delete this.commentReplyRedraftValue+ this.commentReplyRedraftValue = undefined}onThreadCreated (commentTree: VideoCommentThreadTree) {