X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-watch%2Fvideo-watch.component.ts;h=33de901c02f9a24c4d42368e706d63ecf33fce35;hb=f2eb23cd87cf32b8fe545178143b5f49e06a58da;hp=bc047489e7c78fc24dd4765f798cf7801cc62979;hpb=992f498e312efcde46f818ba719b50f1f958272f;p=github%2FChocobozzz%2FPeerTube.git
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 bc047489e..33de901c0 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -39,6 +39,7 @@ import { isWebRTCDisabled, timeToInt } from '../../../assets/player/utils'
import { environment } from '../../../environments/environment'
import { VideoSupportComponent } from './modal/video-support.component'
import { VideoWatchPlaylistComponent } from './video-watch-playlist.component'
+import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
type URLOptions = CustomizationOptions & { playerMode: PlayerMode }
@@ -219,12 +220,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
return $localize`You need to be logged in to rate this video.`
}
- getExactNumberOfViews () {
- return (this.video.views >= 1000)
- ? `${this.video.views} ${this.video.isLive ? $localize`viewers` : $localize`views`}`
- : ''
- }
-
showMoreDescription () {
if (this.completeVideoDescription === undefined) {
return this.loadCompleteDescription()
@@ -418,13 +413,25 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
$localize`This video is not available on this instance. Do you want to be redirected on the origin instance: ${originUrl}?`,
$localize`Redirection`
).then(res => {
- if (res === false) return this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])
+ if (res === false) {
+ return this.restExtractor.redirectTo404IfNotFound(err, [
+ HttpStatusCode.BAD_REQUEST_400,
+ HttpStatusCode.UNAUTHORIZED_401,
+ HttpStatusCode.FORBIDDEN_403,
+ HttpStatusCode.NOT_FOUND_404
+ ])
+ }
return window.location.href = originUrl
})
}
- return this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])
+ return this.restExtractor.redirectTo404IfNotFound(err, [
+ HttpStatusCode.BAD_REQUEST_400,
+ HttpStatusCode.UNAUTHORIZED_401,
+ HttpStatusCode.FORBIDDEN_403,
+ HttpStatusCode.NOT_FOUND_404
+ ])
})
)
.subscribe(([ video, captionsResult ]) => {
@@ -456,7 +463,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
this.playlistService.getVideoPlaylist(playlistId)
.pipe(
// If 401, the video is private or blocked so redirect to 404
- catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
+ catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [
+ HttpStatusCode.BAD_REQUEST_400,
+ HttpStatusCode.UNAUTHORIZED_401,
+ HttpStatusCode.FORBIDDEN_403,
+ HttpStatusCode.NOT_FOUND_404
+ ]))
)
.subscribe(playlist => {
this.playlist = playlist
@@ -613,6 +625,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
}
})
+ this.player.one('ended', () => {
+ if (this.video.isLive) {
+ this.video.state.id = VideoState.LIVE_ENDED
+ }
+ })
+
this.player.on('theaterChange', (_: any, enabled: boolean) => {
this.zone.run(() => this.theaterEnabled = enabled)
})
@@ -850,7 +868,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
if (!this.liveVideosSub) {
this.liveVideosSub = this.peertubeSocket.getLiveVideosObservable()
.subscribe(({ payload }) => {
- if (payload.state !== VideoState.PUBLISHED || this.video.state.id !== VideoState.WAITING_FOR_LIVE) return
+ if (payload.state !== VideoState.PUBLISHED) return
+
+ const videoState = this.video.state.id
+ if (videoState !== VideoState.WAITING_FOR_LIVE && videoState !== VideoState.LIVE_ENDED) return
+
+ console.log('Loading video after live update.')
const videoUUID = this.video.uuid