From 6cb556449064278bdcb1a54a7b980c2e7bc735f0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 20 Mar 2020 14:43:12 +0100 Subject: Fix add comment in threads with deleted comments --- .../videos/+video-watch/comment/video-comment-add.component.ts | 2 +- .../app/videos/+video-watch/comment/video-comment.component.ts | 9 +++++++-- .../app/videos/+video-watch/comment/video-comments.component.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'client/src') diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index 5784efcdf..0f7c19765 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -57,7 +57,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { if (this.parentComment) { const mentions = this.parentComments - .filter(c => c.account.id !== this.user.account.id) // Don't add mention of ourselves + .filter(c => c.account && c.account.id !== this.user.account.id) // Don't add mention of ourselves .map(c => '@' + c.by) const mentionsSet = new Set(mentions) diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index f7eca45fd..1313b6585 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -125,7 +125,12 @@ export class VideoCommentComponent implements OnInit, OnChanges { const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true) this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html) this.newParentComments = this.parentComments.concat([ this.comment ]) - this.commentAccount = new Account(this.comment.account) - this.getUserIfNeeded(this.commentAccount) + + if (this.comment.account) { + this.commentAccount = new Account(this.comment.account) + this.getUserIfNeeded(this.commentAccount) + } else { + this.comment.account = null + } } } 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 f2bb5c464..f1408effb 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 @@ -183,7 +183,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { // Mark the comment as deleted this.softDeleteComment(commentToDelete) - if (this.highlightedThread.id === commentToDelete.id) this.highlightedThread = undefined + if (this.highlightedThread?.id === commentToDelete.id) this.highlightedThread = undefined }, err => this.notifier.error(err.message) -- cgit v1.2.3