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 --- .../comment/video-comments.component.ts | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'client/src/app/+videos/+video-watch/comment/video-comments.component.ts') 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.ts index 517844ab2..8080afd8d 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 @@ -27,6 +27,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { totalItems: null } inReplyToCommentId: number + commentReplyRedraftValue: string + commentThreadRedraftValue: string threadComments: { [ id: number ]: VideoCommentThreadTree } = {} threadLoading: { [ id: number ]: boolean } = {} @@ -131,6 +133,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { onCommentThreadCreated (comment: VideoComment) { this.comments.unshift(comment) + delete this.commentThreadRedraftValue } onWantedToReply (comment: VideoComment) { @@ -139,6 +142,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { onResetReply () { this.inReplyToCommentId = undefined + delete this.commentReplyRedraftValue } onThreadCreated (commentTree: VideoCommentThreadTree) { @@ -156,9 +160,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.timestampClicked.emit(timestamp) } - async onWantedToDelete (commentToDelete: VideoComment) { - let message = 'Do you really want to delete this comment?' - + async onWantedToDelete (commentToDelete: VideoComment, message = 'Do you really want to delete this comment?'): Promise { if (commentToDelete.isLocal || this.video.isLocal) { message += $localize` The deletion will be sent to remote instances so they can reflect the change.` } else { @@ -183,6 +185,23 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { err => this.notifier.error(err.message) ) + + return true + } + + async onWantedToRedraft(commentToRedraft: VideoComment) { + const confirm = await this.onWantedToDelete(commentToRedraft, 'Do you really want to delete and re-draft this comment?') + + if (confirm) { + this.inReplyToCommentId = commentToRedraft.inReplyToCommentId + + if (commentToRedraft.threadId === commentToRedraft.id) { + this.commentThreadRedraftValue = commentToRedraft.text + } else { + this.commentReplyRedraftValue = commentToRedraft.text + } + + } } isUserLoggedIn () { -- cgit v1.2.3