diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/+videos/+video-watch/video-watch-playlist.component.ts | 3 | ||||
-rw-r--r-- | client/src/app/+videos/+video-watch/video-watch.component.ts | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts index a70167da5..0a4d6bfd1 100644 --- a/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch-playlist.component.ts | |||
@@ -118,6 +118,9 @@ export class VideoWatchPlaylistComponent { | |||
118 | updatePlaylistIndex (position: number) { | 118 | updatePlaylistIndex (position: number) { |
119 | if (this.playlistElements.length === 0 || !position) return | 119 | if (this.playlistElements.length === 0 || !position) return |
120 | 120 | ||
121 | // Handle the reverse index | ||
122 | if (position < 0) position = this.playlist.videosLength + position + 1 | ||
123 | |||
121 | for (const playlistElement of this.playlistElements) { | 124 | for (const playlistElement of this.playlistElements) { |
122 | // >= if the previous videos were not valid | 125 | // >= if the previous videos were not valid |
123 | if (playlistElement.video && playlistElement.position >= position) { | 126 | if (playlistElement.video && playlistElement.position >= position) { |
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 5530dc8ad..107826824 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 { | |||
188 | }) | 188 | }) |
189 | 189 | ||
190 | this.queryParamsSub = this.route.queryParams.subscribe(queryParams => { | 190 | this.queryParamsSub = this.route.queryParams.subscribe(queryParams => { |
191 | this.playlistPosition = queryParams[ 'playlistPosition' ] | 191 | // Handle the ?playlistPosition |
192 | const positionParam = queryParams[ 'playlistPosition' ] | ||
193 | |||
194 | this.playlistPosition = positionParam === 'last' | ||
195 | ? -1 // Handle the "last" index | ||
196 | : parseInt(positionParam, 10) | ||
197 | |||
198 | if (isNaN(this.playlistPosition)) { | ||
199 | console.error(`playlistPosition query param '${positionParam}' was parsed as NaN, defaulting to 1.`) | ||
200 | this.playlistPosition = 1 | ||
201 | } | ||
202 | |||
192 | this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition) | 203 | this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition) |
193 | 204 | ||
194 | const start = queryParams[ 'start' ] | 205 | const start = queryParams[ 'start' ] |