aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos
diff options
context:
space:
mode:
authorFlorian CUNY <poslovitch@bentobox.world>2021-04-26 11:01:29 +0200
committerGitHub <noreply@github.com>2021-04-26 11:01:29 +0200
commite771e82dfac5f8cd5462fecf6618f9b1fb314e30 (patch)
tree6abf1789ad2603ad975c31b9a513ad60b8fde8d7 /client/src/app/+videos
parentfd78d2e247b014fd1561cfb5206c9b8b14d6b820 (diff)
downloadPeerTube-e771e82dfac5f8cd5462fecf6618f9b1fb314e30.tar.gz
PeerTube-e771e82dfac5f8cd5462fecf6618f9b1fb314e30.tar.zst
PeerTube-e771e82dfac5f8cd5462fecf6618f9b1fb314e30.zip
Added "last" and a reversed ?playlistPosition in playlist URL (#3974)
* Added "last" and a reversed playlistPosition Implements https://github.com/Chocobozzz/PeerTube/issues/3897 * Fixed lint errors in video-watch component * Applied requested changes * Removed debug logs * Fixed lint * Playlist position styling Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'client/src/app/+videos')
-rw-r--r--client/src/app/+videos/+video-watch/video-watch-playlist.component.ts3
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts13
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' ]