From 1f30a1853e38c20a45722dbd6d38aaaec63839e8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Feb 2018 15:29:32 +0100 Subject: Add confirm when admin use custom js/css --- .../comment/video-comments.component.ts | 55 ++++++++++------------ 1 file changed, 26 insertions(+), 29 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 16f1a0643..711a01ba0 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 @@ -109,38 +109,35 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.viewReplies(commentTree.comment.id) } - onWantedToDelete (commentToDelete: VideoComment) { + async onWantedToDelete (commentToDelete: VideoComment) { let message = 'Do you really want to delete this comment?' if (commentToDelete.totalReplies !== 0) message += `${commentToDelete.totalReplies} would be deleted too.` - this.confirmService.confirm(message, 'Delete').subscribe( - res => { - if (res === false) return - - this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) - .subscribe( - () => { - // Delete the comment in the tree - if (commentToDelete.inReplyToCommentId) { - const thread = this.threadComments[commentToDelete.threadId] - if (!thread) { - console.error(`Cannot find thread ${commentToDelete.threadId} of the comment to delete ${commentToDelete.id}`) - return - } - - this.deleteLocalCommentThread(thread, commentToDelete) - return - } - - // Delete the thread - this.comments = this.comments.filter(c => c.id !== commentToDelete.id) - this.componentPagination.totalItems-- - }, - - err => this.notificationsService.error('Error', err.message) - ) - } - ) + const res = await this.confirmService.confirm(message, 'Delete') + if (res === false) return + + this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) + .subscribe( + () => { + // Delete the comment in the tree + if (commentToDelete.inReplyToCommentId) { + const thread = this.threadComments[commentToDelete.threadId] + if (!thread) { + console.error(`Cannot find thread ${commentToDelete.threadId} of the comment to delete ${commentToDelete.id}`) + return + } + + this.deleteLocalCommentThread(thread, commentToDelete) + return + } + + // Delete the thread + this.comments = this.comments.filter(c => c.id !== commentToDelete.id) + this.componentPagination.totalItems-- + }, + + err => this.notificationsService.error('Error', err.message) + ) } isUserLoggedIn () { -- cgit v1.2.3