From 5a9a56b78f6a62b3241f0dff1b8685001a3b3a1d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Jul 2022 10:32:56 +0200 Subject: Prevent error on highlighted thread --- .../shared/comment/video-comments.component.ts | 14 +++++++++++++- .../src/app/+videos/+video-watch/video-watch.component.ts | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'client/src/app/+videos') diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts index 1652fd3c4..108ad63e3 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts @@ -5,6 +5,7 @@ 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 { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' @Component({ selector: 'my-video-comments', @@ -104,7 +105,14 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { } }, - error: err => this.notifier.error(err.message) + error: err => { + // We may try to fetch highlighted thread of another video, skip the error if it is the case + // We'll retry the request on video Input() change + const errorBody = err.body as PeerTubeProblemDocument + if (highlightThread && errorBody?.code === ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO) return + + this.notifier.error(err.message) + } }) } @@ -254,6 +262,10 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.syndicationItems = this.videoCommentService.getVideoCommentsFeeds(this.video) this.loadMoreThreads() + + if (this.activatedRoute.params['threadId']) { + this.processHighlightedThread(+this.activatedRoute.params['threadId']) + } } } diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 292ce6441..8d9c08ab3 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -242,6 +242,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { if (this.player) this.player.pause() + this.video = undefined + const videoObs = this.hooks.wrapObsFun( this.videoService.getVideo.bind(this.videoService), { videoId }, -- cgit v1.2.3