X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-watch%2Fvideo-watch.component.ts;h=116139d473e372fa39db69415c3914904b069904;hb=7a9e9417c17f8a45a639e7c3f49d82f14985786e;hp=025c62430c5134a2647f1da5da23863c4f0b92b0;hpb=dfdcbb948aa2440efc2425569dce947c9cb00378;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 025c62430..116139d47 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -188,7 +188,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { }) this.queryParamsSub = this.route.queryParams.subscribe(queryParams => { - this.playlistPosition = queryParams[ 'playlistPosition' ] + // Handle the ?playlistPosition + const positionParam = queryParams[ 'playlistPosition' ] ?? 1 + + this.playlistPosition = positionParam === 'last' + ? -1 // Handle the "last" index + : parseInt(positionParam + '', 10) + + if (isNaN(this.playlistPosition)) { + console.error(`playlistPosition query param '${positionParam}' was parsed as NaN, defaulting to 1.`) + this.playlistPosition = 1 + } + this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition) const start = queryParams[ 'start' ] @@ -663,7 +674,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.player.one('ended', () => { if (this.video.isLive) { - this.video.state.id = VideoState.LIVE_ENDED + this.zone.run(() => this.video.state.id = VideoState.LIVE_ENDED) } }) @@ -848,8 +859,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } // Only set this if we're in a playlist - if (this.playlist) options.common.previousVideo = () => { - this.zone.run(() => this.videoWatchPlaylist.navigateToPreviousPlaylistVideo()) + if (this.playlist) { + options.common.previousVideo = () => { + this.zone.run(() => this.videoWatchPlaylist.navigateToPreviousPlaylistVideo()) + } } let mode: PlayerMode