]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts
Merge branch 'release/v1.3.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-video-playlists / my-account-video-playlist-elements.component.ts
index dcf470be3748e3f8d7ccfcca025e41fd14cccfdc..03f34412cabdd6e372104589278211cc79874105 100644 (file)
@@ -24,7 +24,7 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro
 
   pagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 10,
+    itemsPerPage: 30,
     totalItems: null
   }
 
@@ -67,7 +67,9 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro
     if (previousIndex === newIndex) return
 
     const oldPosition = this.videos[previousIndex].playlistElement.position
-    const insertAfter = newIndex === 0 ? 0 : this.videos[newIndex].playlistElement.position
+    let insertAfter = this.videos[newIndex].playlistElement.position
+
+    if (oldPosition > insertAfter) insertAfter--
 
     this.videoPlaylistService.reorderPlaylist(this.playlist.id, oldPosition, insertAfter)
       .subscribe(
@@ -123,6 +125,10 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro
     this.loadElements()
   }
 
+  trackByFn (index: number, elem: Video) {
+    return elem.id
+  }
+
   private loadElements () {
     this.videoService.getPlaylistVideos(this.videoPlaylistId, this.pagination)
         .subscribe(({ totalVideos, videos }) => {