aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts14
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts2
-rw-r--r--server/middlewares/validators/shared/video-comments.ts12
-rw-r--r--shared/models/server/server-error-code.enum.ts4
4 files changed, 27 insertions, 5 deletions
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
5import { HooksService } from '@app/core/plugins/hooks.service' 5import { HooksService } from '@app/core/plugins/hooks.service'
6import { Syndication, VideoDetails } from '@app/shared/shared-main' 6import { Syndication, VideoDetails } from '@app/shared/shared-main'
7import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/shared/shared-video-comment' 7import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/shared/shared-video-comment'
8import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
8 9
9@Component({ 10@Component({
10 selector: 'my-video-comments', 11 selector: 'my-video-comments',
@@ -104,7 +105,14 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
104 } 105 }
105 }, 106 },
106 107
107 error: err => this.notifier.error(err.message) 108 error: err => {
109 // We may try to fetch highlighted thread of another video, skip the error if it is the case
110 // We'll retry the request on video Input() change
111 const errorBody = err.body as PeerTubeProblemDocument
112 if (highlightThread && errorBody?.code === ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO) return
113
114 this.notifier.error(err.message)
115 }
108 }) 116 })
109 } 117 }
110 118
@@ -254,6 +262,10 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
254 262
255 this.syndicationItems = this.videoCommentService.getVideoCommentsFeeds(this.video) 263 this.syndicationItems = this.videoCommentService.getVideoCommentsFeeds(this.video)
256 this.loadMoreThreads() 264 this.loadMoreThreads()
265
266 if (this.activatedRoute.params['threadId']) {
267 this.processHighlightedThread(+this.activatedRoute.params['threadId'])
268 }
257 } 269 }
258 } 270 }
259 271
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 {
242 242
243 if (this.player) this.player.pause() 243 if (this.player) this.player.pause()
244 244
245 this.video = undefined
246
245 const videoObs = this.hooks.wrapObsFun( 247 const videoObs = this.hooks.wrapObsFun(
246 this.videoService.getVideo.bind(this.videoService), 248 this.videoService.getVideo.bind(this.videoService),
247 { videoId }, 249 { videoId },
diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/middlewares/validators/shared/video-comments.ts
index 386ae911f..8d1a16294 100644
--- a/server/middlewares/validators/shared/video-comments.ts
+++ b/server/middlewares/validators/shared/video-comments.ts
@@ -1,7 +1,7 @@
1import express from 'express' 1import express from 'express'
2import { VideoCommentModel } from '@server/models/video/video-comment' 2import { VideoCommentModel } from '@server/models/video/video-comment'
3import { MVideoId } from '@server/types/models' 3import { MVideoId } from '@server/types/models'
4import { HttpStatusCode } from '@shared/models' 4import { HttpStatusCode, ServerErrorCode } from '@shared/models'
5 5
6async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { 6async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
7 const id = parseInt(idArg + '', 10) 7 const id = parseInt(idArg + '', 10)
@@ -16,7 +16,10 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide
16 } 16 }
17 17
18 if (videoComment.videoId !== video.id) { 18 if (videoComment.videoId !== video.id) {
19 res.fail({ message: 'Video comment is not associated to this video.' }) 19 res.fail({
20 type: ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO,
21 message: 'Video comment is not associated to this video.'
22 })
20 return false 23 return false
21 } 24 }
22 25
@@ -42,7 +45,10 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r
42 } 45 }
43 46
44 if (videoComment.videoId !== video.id) { 47 if (videoComment.videoId !== video.id) {
45 res.fail({ message: 'Video comment is not associated to this video.' }) 48 res.fail({
49 type: ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO,
50 message: 'Video comment is not associated to this video.'
51 })
46 return false 52 return false
47 } 53 }
48 54
diff --git a/shared/models/server/server-error-code.enum.ts b/shared/models/server/server-error-code.enum.ts
index 115421d4d..0e70ea0a7 100644
--- a/shared/models/server/server-error-code.enum.ts
+++ b/shared/models/server/server-error-code.enum.ts
@@ -37,7 +37,9 @@ export const enum ServerErrorCode {
37 * A torrent should have at most one correct video file. Any more and we will 37 * A torrent should have at most one correct video file. Any more and we will
38 * not be able to choose automatically. 38 * not be able to choose automatically.
39 */ 39 */
40 INCORRECT_FILES_IN_TORRENT = 'incorrect_files_in_torrent' 40 INCORRECT_FILES_IN_TORRENT = 'incorrect_files_in_torrent',
41
42 COMMENT_NOT_ASSOCIATED_TO_VIDEO = 'comment_not_associated_to_video'
41} 43}
42 44
43/** 45/**