onCommentThreadCreated (comment: VideoComment) {
this.comments.unshift(comment)
- delete this.commentThreadRedraftValue
+ this.commentThreadRedraftValue = undefined
}
onWantedToReply (comment: VideoComment) {
onResetReply () {
this.inReplyToCommentId = undefined
- delete this.commentReplyRedraftValue
+ this.commentReplyRedraftValue = undefined
}
onThreadCreated (commentTree: VideoCommentThreadTree) {
this.timestampClicked.emit(timestamp)
}
- async onWantedToDelete (commentToDelete: VideoComment, message = 'Do you really want to delete this comment?'): Promise<boolean> {
+ async onWantedToDelete (
+ commentToDelete: VideoComment,
+ title = $localize`Delete`,
+ message = $localize`Do you really want to delete this comment?`
+ ): Promise<boolean> {
if (commentToDelete.isLocal || this.video.isLocal) {
message += $localize` The deletion will be sent to remote instances so they can reflect the change.`
} else {
message += $localize` It is a remote comment, so the deletion will only be effective on your instance.`
}
- const res = await this.confirmService.confirm(message, $localize`Delete`)
- if (res === false) return
+ const res = await this.confirmService.confirm(message, title)
+ if (res === false) return false
this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id)
.subscribe(
return true
}
- async onWantedToRedraft(commentToRedraft: VideoComment) {
- const confirm = await this.onWantedToDelete(commentToRedraft, 'Do you really want to delete and re-draft this comment?')
+ async onWantedToRedraft (commentToRedraft: VideoComment) {
+ const confirm = await this.onWantedToDelete(commentToRedraft, $localize`Delete and re-draft`, $localize`Do you really want to delete and re-draft this comment?`)
if (confirm) {
this.inReplyToCommentId = commentToRedraft.inReplyToCommentId
+ // Restore line feed for editing
+ const commentToRedraftText = commentToRedraft.text.replace(/<br.?\/?>/g, '\r\n')
+
if (commentToRedraft.threadId === commentToRedraft.id) {
- this.commentThreadRedraftValue = commentToRedraft.text
+ this.commentThreadRedraftValue = commentToRedraftText
} else {
- this.commentReplyRedraftValue = commentToRedraft.text
+ this.commentReplyRedraftValue = commentToRedraftText
}
}