comments: VideoComment[] = []
highlightedThread: VideoComment
+
sort = '-createdAt'
+
componentPagination: ComponentPagination = {
currentPage: 1,
itemsPerPage: 10,
totalItems: null
}
+ totalNotDeletedComments: number
+
inReplyToCommentId: number
commentReplyRedraftValue: string
commentThreadRedraftValue: string
+
threadComments: { [ id: number ]: VideoCommentThreadTree } = {}
threadLoading: { [ id: number ]: boolean } = {}
res => {
this.comments = this.comments.concat(res.data)
this.componentPagination.totalItems = res.total
+ this.totalNotDeletedComments = res.totalNotDeletedComments
this.onDataSubject.next(res.data)
this.hooks.runAction('action:video-watch.video-threads.loaded', 'video-watch', { data: this.componentPagination })
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, title = $localize`Delete`, message = $localize`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 {
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
}
}
this.inReplyToCommentId = undefined
this.componentPagination.currentPage = 1
this.componentPagination.totalItems = null
+ this.totalNotDeletedComments = null
this.syndicationItems = this.videoCommentService.getVideoCommentsFeeds(this.video.uuid)
this.loadMoreThreads()