diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-22 15:29:32 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-22 15:29:32 +0100 |
commit | 1f30a1853e38c20a45722dbd6d38aaaec63839e8 (patch) | |
tree | cdce8cc9fcc62d9b3343c9478b1dbcefedcea972 /client/src/app/videos/+video-watch/comment | |
parent | 78967fca4cacbc247fa6fb62d64b2d6825a10804 (diff) | |
download | PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.gz PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.zst PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.zip |
Add confirm when admin use custom js/css
Diffstat (limited to 'client/src/app/videos/+video-watch/comment')
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comments.component.ts | 55 |
1 files changed, 26 insertions, 29 deletions
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 { | |||
109 | this.viewReplies(commentTree.comment.id) | 109 | this.viewReplies(commentTree.comment.id) |
110 | } | 110 | } |
111 | 111 | ||
112 | onWantedToDelete (commentToDelete: VideoComment) { | 112 | async onWantedToDelete (commentToDelete: VideoComment) { |
113 | let message = 'Do you really want to delete this comment?' | 113 | let message = 'Do you really want to delete this comment?' |
114 | if (commentToDelete.totalReplies !== 0) message += `${commentToDelete.totalReplies} would be deleted too.` | 114 | if (commentToDelete.totalReplies !== 0) message += `${commentToDelete.totalReplies} would be deleted too.` |
115 | 115 | ||
116 | this.confirmService.confirm(message, 'Delete').subscribe( | 116 | const res = await this.confirmService.confirm(message, 'Delete') |
117 | res => { | 117 | if (res === false) return |
118 | if (res === false) return | 118 | |
119 | 119 | this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) | |
120 | this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) | 120 | .subscribe( |
121 | .subscribe( | 121 | () => { |
122 | () => { | 122 | // Delete the comment in the tree |
123 | // Delete the comment in the tree | 123 | if (commentToDelete.inReplyToCommentId) { |
124 | if (commentToDelete.inReplyToCommentId) { | 124 | const thread = this.threadComments[commentToDelete.threadId] |
125 | const thread = this.threadComments[commentToDelete.threadId] | 125 | if (!thread) { |
126 | if (!thread) { | 126 | console.error(`Cannot find thread ${commentToDelete.threadId} of the comment to delete ${commentToDelete.id}`) |
127 | console.error(`Cannot find thread ${commentToDelete.threadId} of the comment to delete ${commentToDelete.id}`) | 127 | return |
128 | return | 128 | } |
129 | } | 129 | |
130 | 130 | this.deleteLocalCommentThread(thread, commentToDelete) | |
131 | this.deleteLocalCommentThread(thread, commentToDelete) | 131 | return |
132 | return | 132 | } |
133 | } | 133 | |
134 | 134 | // Delete the thread | |
135 | // Delete the thread | 135 | this.comments = this.comments.filter(c => c.id !== commentToDelete.id) |
136 | this.comments = this.comments.filter(c => c.id !== commentToDelete.id) | 136 | this.componentPagination.totalItems-- |
137 | this.componentPagination.totalItems-- | 137 | }, |
138 | }, | 138 | |
139 | 139 | err => this.notificationsService.error('Error', err.message) | |
140 | err => this.notificationsService.error('Error', err.message) | 140 | ) |
141 | ) | ||
142 | } | ||
143 | ) | ||
144 | } | 141 | } |
145 | 142 | ||
146 | isUserLoggedIn () { | 143 | isUserLoggedIn () { |