ActivityPub-federated video streaming platform using P2P directly in your web browser
Correctly reload playlist on playlist change
Chocobozzz09d5fcabd625
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.tsindex 4f637cd9c3..dbf1d4690f 100644--- a/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.ts+++ b/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.ts@@ -75,7 +75,7 @@ export class VideoWatchPlaylistComponent {if (this.playlistPagination.totalItems <= (this.playlistPagination.currentPage * this.playlistPagination.itemsPerPage)) returnthis.playlistPagination.currentPage += 1- this.loadPlaylistElements(this.playlist(), false, position)+ this.loadPlaylistElements({ playlist: this.playlist(), redirectToFirst: false, position })}onElementRemoved (playlistElement: VideoPlaylistElement) {@@ -103,7 +103,14 @@ export class VideoWatchPlaylistComponent {return this.playlist().privacy.id === VideoPlaylistPrivacy.PUBLIC}- loadPlaylistElements (playlist: VideoPlaylist, redirectToFirst = false, position?: number) {+ loadPlaylistElements (options: {+ playlist: VideoPlaylist+ redirectToFirst?: boolean // default false+ reset?: boolean // default false+ position?: number+ }) {+ const { playlist, redirectToFirst = false, reset = false, position } = options+const obs = this.hooks.wrapObsFun(this.videoPlaylist.getPlaylistVideos.bind(this.videoPlaylist),{ videoPlaylistId: playlist.uuid, componentPagination: this.playlistPagination },@@ -113,6 +120,8 @@ export class VideoWatchPlaylistComponent {)obs.subscribe(({ total, data: playlistElements }) => {+ if (reset) this.playlistElements = []+this.playlistElements = this.playlistElements.concat(playlistElements)this.playlistPagination.totalItems = totaldiff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.tsindex 24c663eed0..194d63815d 100644--- a/client/src/app/+videos/+video-watch/video-watch.component.ts+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts@@ -1,6 +1,6 @@import { NgClass, NgIf, NgTemplateOutlet, PlatformLocation } from '@angular/common'import { Component, ElementRef, LOCALE_ID, NgZone, OnDestroy, OnInit, inject, viewChild } from '@angular/core'-import { ActivatedRoute, Router, RouterLink } from '@angular/router'+import { ActivatedRoute, Params, Router, RouterLink } from '@angular/router'import {AuthService,AuthUser,@@ -309,18 +309,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {private loadRouteQuery () {this.queryParamsSub = this.route.queryParams.subscribe(queryParams => {- // Handle the ?playlistPosition- const positionParam = queryParams['playlistPosition']- if (!positionParam) return-- this.playlistPosition = positionParam === 'last'- ? -1 // Handle the "last" index- : parseInt(positionParam + '', 10)-- if (isNaN(this.playlistPosition)) {- logger.error(`playlistPosition query param '${positionParam}' was parsed as NaN, defaulting to 1.`)- this.playlistPosition = 1- }+ if (!this.parsePlaylistPosition(queryParams)) returnthis.videoWatchPlaylist().updatePlaylistIndex(this.playlistPosition)@@ -331,6 +320,23 @@ export class VideoWatchComponent implements OnInit, OnDestroy {})}+ private parsePlaylistPosition (queryParams: Params) {+ // Handle the ?playlistPosition+ const positionParam = queryParams['playlistPosition']+ if (!positionParam) return false++ this.playlistPosition = positionParam === 'last'+ ? -1 // Handle the "last" index+ : parseInt(positionParam + '', 10)++ if (isNaN(this.playlistPosition)) {+ logger.error(`playlistPosition query param '${positionParam}' was parsed as NaN, defaulting to 1.`)+ this.playlistPosition = 1+ }++ return true+ }+private loadVideo (options: {videoId: stringforceAutoplay: boolean@@ -403,6 +409,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {private loadPlaylist (playlistId: string) {if (this.isSameElement(this.playlist, playlistId)) return+ this.playlistPosition = undefinedthis.noPlaylistVideoFound = falsethis.playlistService.getVideoPlaylist(playlistId)@@ -410,7 +417,14 @@ export class VideoWatchComponent implements OnInit, OnDestroy {next: playlist => {this.playlist = playlist- this.videoWatchPlaylist().loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition)+ this.parsePlaylistPosition(this.route.snapshot.queryParams)++ this.videoWatchPlaylist().loadPlaylistElements({+ playlist,+ redirectToFirst: !this.playlistPosition,+ position: this.playlistPosition,+ reset: true+ })},error: err => this.handleRequestError(err)