X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-watch%2Fcomment%2Fvideo-comments.component.ts;h=adce31c5bb52ea4cbd8f3f59e787c94089f29f01;hb=fdd1296521354401e9927e5faeb0aa17ba810c41;hp=66494a20abbf12e6d8dbb4ea7b687cb09aedf268;hpb=17aa80ed016bafa3ccb071af3f86054033823284;p=github%2FChocobozzz%2FPeerTube.git 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 66494a20a..adce31c5b 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 @@ -5,7 +5,6 @@ import { AuthService, ComponentPagination, ConfirmService, hasMoreItems, Notifie import { HooksService } from '@app/core/plugins/hooks.service' import { Syndication, VideoDetails } from '@app/shared/shared-main' import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/shared/shared-video-comment' -import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-video-comments', @@ -28,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 } = {} @@ -43,7 +44,6 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { private confirmService: ConfirmService, private videoCommentService: VideoCommentService, private activatedRoute: ActivatedRoute, - private i18n: I18n, private hooks: HooksService ) {} @@ -133,6 +133,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { onCommentThreadCreated (comment: VideoComment) { this.comments.unshift(comment) + this.commentThreadRedraftValue = undefined } onWantedToReply (comment: VideoComment) { @@ -141,6 +142,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { onResetReply () { this.inReplyToCommentId = undefined + this.commentReplyRedraftValue = undefined } onThreadCreated (commentTree: VideoCommentThreadTree) { @@ -158,17 +160,15 @@ 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, title = $localize`Delete`, message = $localize`Do you really want to delete this comment?`): Promise { if (commentToDelete.isLocal || this.video.isLocal) { - message += this.i18n(' The deletion will be sent to remote instances so they can reflect the change.') + message += $localize` The deletion will be sent to remote instances so they can reflect the change.` } else { - message += this.i18n(' It is a remote comment, so the deletion will only be effective on your instance.') + message += $localize` It is a remote comment, so the deletion will only be effective on your instance.` } - const res = await this.confirmService.confirm(message, this.i18n('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( @@ -185,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, $localize`Delete and re-draft`, $localize`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 () {