From f63c03fb6ecccb5ac8e0d88917f072339b38ffb5 Mon Sep 17 00:00:00 2001 From: kimsible Date: Fri, 7 Aug 2020 14:03:28 +0200 Subject: Add delete & re-draft for comments without replies --- .../+video-watch/comment/video-comment.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'client/src/app/+videos/+video-watch/comment/video-comment.component.ts') diff --git a/client/src/app/+videos/+video-watch/comment/video-comment.component.ts b/client/src/app/+videos/+video-watch/comment/video-comment.component.ts index a84e91fd3..507132909 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 @@ -22,9 +22,11 @@ export class VideoCommentComponent implements OnInit, OnChanges { @Input() inReplyToCommentId: number @Input() highlightedComment = false @Input() firstInThread = false + @Input() redraftValue?: string - @Output() wantedToDelete = new EventEmitter() @Output() wantedToReply = new EventEmitter() + @Output() wantedToDelete = new EventEmitter() + @Output() wantedToRedraft = new EventEmitter() @Output() threadCreated = new EventEmitter() @Output() resetReply = new EventEmitter() @Output() timestampClicked = new EventEmitter() @@ -70,7 +72,10 @@ export class VideoCommentComponent implements OnInit, OnChanges { comment: createdComment, children: [] }) + this.resetReply.emit() + + delete this.redraftValue } onWantToReply (comment?: VideoComment) { @@ -81,6 +86,10 @@ export class VideoCommentComponent implements OnInit, OnChanges { this.wantedToDelete.emit(comment || this.comment) } + onWantToRedraft (comment?: VideoComment) { + this.wantedToRedraft.emit(comment || this.comment) + } + isUserLoggedIn () { return this.authService.isLoggedIn() } @@ -102,6 +111,10 @@ export class VideoCommentComponent implements OnInit, OnChanges { ) } + isRedraftableByUser () { + return this.comment.account && this.isUserLoggedIn() && this.user.account.id === this.comment.account.id && this.comment.totalReplies === 0 + } + switchToDefaultAvatar ($event: Event) { ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() } -- cgit v1.2.3