diff options
Diffstat (limited to 'client/src/app/+videos/+video-watch/comment/video-comments.component.ts')
-rw-r--r-- | client/src/app/+videos/+video-watch/comment/video-comments.component.ts | 25 |
1 files changed, 22 insertions, 3 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 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 { | |||
27 | totalItems: null | 27 | totalItems: null |
28 | } | 28 | } |
29 | inReplyToCommentId: number | 29 | inReplyToCommentId: number |
30 | commentReplyRedraftValue: string | ||
31 | commentThreadRedraftValue: string | ||
30 | threadComments: { [ id: number ]: VideoCommentThreadTree } = {} | 32 | threadComments: { [ id: number ]: VideoCommentThreadTree } = {} |
31 | threadLoading: { [ id: number ]: boolean } = {} | 33 | threadLoading: { [ id: number ]: boolean } = {} |
32 | 34 | ||
@@ -131,6 +133,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { | |||
131 | 133 | ||
132 | onCommentThreadCreated (comment: VideoComment) { | 134 | onCommentThreadCreated (comment: VideoComment) { |
133 | this.comments.unshift(comment) | 135 | this.comments.unshift(comment) |
136 | delete this.commentThreadRedraftValue | ||
134 | } | 137 | } |
135 | 138 | ||
136 | onWantedToReply (comment: VideoComment) { | 139 | onWantedToReply (comment: VideoComment) { |
@@ -139,6 +142,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { | |||
139 | 142 | ||
140 | onResetReply () { | 143 | onResetReply () { |
141 | this.inReplyToCommentId = undefined | 144 | this.inReplyToCommentId = undefined |
145 | delete this.commentReplyRedraftValue | ||
142 | } | 146 | } |
143 | 147 | ||
144 | onThreadCreated (commentTree: VideoCommentThreadTree) { | 148 | onThreadCreated (commentTree: VideoCommentThreadTree) { |
@@ -156,9 +160,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { | |||
156 | this.timestampClicked.emit(timestamp) | 160 | this.timestampClicked.emit(timestamp) |
157 | } | 161 | } |
158 | 162 | ||
159 | async onWantedToDelete (commentToDelete: VideoComment) { | 163 | async onWantedToDelete (commentToDelete: VideoComment, message = 'Do you really want to delete this comment?'): Promise<boolean> { |
160 | let message = 'Do you really want to delete this comment?' | ||
161 | |||
162 | if (commentToDelete.isLocal || this.video.isLocal) { | 164 | if (commentToDelete.isLocal || this.video.isLocal) { |
163 | message += $localize` The deletion will be sent to remote instances so they can reflect the change.` | 165 | message += $localize` The deletion will be sent to remote instances so they can reflect the change.` |
164 | } else { | 166 | } else { |
@@ -183,6 +185,23 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { | |||
183 | 185 | ||
184 | err => this.notifier.error(err.message) | 186 | err => this.notifier.error(err.message) |
185 | ) | 187 | ) |
188 | |||
189 | return true | ||
190 | } | ||
191 | |||
192 | async onWantedToRedraft(commentToRedraft: VideoComment) { | ||
193 | const confirm = await this.onWantedToDelete(commentToRedraft, 'Do you really want to delete and re-draft this comment?') | ||
194 | |||
195 | if (confirm) { | ||
196 | this.inReplyToCommentId = commentToRedraft.inReplyToCommentId | ||
197 | |||
198 | if (commentToRedraft.threadId === commentToRedraft.id) { | ||
199 | this.commentThreadRedraftValue = commentToRedraft.text | ||
200 | } else { | ||
201 | this.commentReplyRedraftValue = commentToRedraft.text | ||
202 | } | ||
203 | |||
204 | } | ||
186 | } | 205 | } |
187 | 206 | ||
188 | isUserLoggedIn () { | 207 | isUserLoggedIn () { |