Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ export class VideoWatchPlaylistComponent {
updatePlaylistIndex (position: number) {
if (this.playlistElements.length === 0 || !position) return

// Handle the reverse index
if (position < 0) position = this.playlist.videosLength + position + 1

for (const playlistElement of this.playlistElements) {
// >= if the previous videos were not valid
if (playlistElement.video && playlistElement.position >= position) {
Expand Down
13 changes: 12 additions & 1 deletion client/src/app/+videos/+video-watch/video-watch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]

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' ]
Expand Down