@@ -330,7 +330,60 @@ export default defineComponent({
330
330
if ( shouldGetNextPage ) { this . getNextPageLocal ( ) }
331
331
} )
332
332
} ,
333
-
333
+ moveVideoTop : function ( videoId , playlistItemId ) {
334
+ const playlistItems = [ ] . concat ( this . playlistItems )
335
+ const videoIndex = playlistItems . findIndex ( ( video ) => {
336
+ return video . videoId === videoId && video . playlistItemId === playlistItemId
337
+ } )
338
+ if ( videoIndex === 0 ) {
339
+ showToast ( this . $t ( 'User Playlists.SinglePlaylistView.Toast["This video cannot be moved to the top."]' ) )
340
+ return
341
+ }
342
+ const videoObject = playlistItems [ videoIndex ]
343
+ playlistItems . splice ( videoIndex , 1 )
344
+ playlistItems . unshift ( videoObject )
345
+ const playlist = {
346
+ playlistName : this . playlistTitle ,
347
+ protected : this . selectedUserPlaylist . protected ,
348
+ description : this . playlistDescription ,
349
+ videos : playlistItems ,
350
+ _id : this . playlistId
351
+ }
352
+ try {
353
+ this . updatePlaylist ( playlist )
354
+ this . playlistItems = playlistItems
355
+ } catch ( e ) {
356
+ showToast ( this . $t ( 'User Playlists.SinglePlaylistView.Toast["There was an issue with updating this playlist."]' ) )
357
+ console . error ( e )
358
+ }
359
+ } ,
360
+ moveVideoBottom : function ( videoId , playlistItemId ) {
361
+ const playlistItems = [ ] . concat ( this . playlistItems )
362
+ const videoIndex = playlistItems . findIndex ( ( video ) => {
363
+ return video . videoId === videoId && video . playlistItemId === playlistItemId
364
+ } )
365
+ if ( videoIndex === playlistItems . length - 1 ) {
366
+ showToast ( this . $t ( 'User Playlists.SinglePlaylistView.Toast["This video cannot be moved to the bottom."]' ) )
367
+ return
368
+ }
369
+ const videoObject = playlistItems [ videoIndex ]
370
+ playlistItems . splice ( videoIndex , 1 )
371
+ playlistItems . push ( videoObject )
372
+ const playlist = {
373
+ playlistName : this . playlistTitle ,
374
+ protected : this . selectedUserPlaylist . protected ,
375
+ description : this . playlistDescription ,
376
+ videos : playlistItems ,
377
+ _id : this . playlistId
378
+ }
379
+ try {
380
+ this . updatePlaylist ( playlist )
381
+ this . playlistItems = playlistItems
382
+ } catch ( e ) {
383
+ showToast ( this . $t ( 'User Playlists.SinglePlaylistView.Toast["There was an issue with updating this playlist."]' ) )
384
+ console . error ( e )
385
+ }
386
+ } ,
334
387
moveVideoUp : function ( videoId , playlistItemId ) {
335
388
const playlistItems = [ ] . concat ( this . playlistItems )
336
389
const videoIndex = playlistItems . findIndex ( ( video ) => {
@@ -362,7 +415,6 @@ export default defineComponent({
362
415
console . error ( e )
363
416
}
364
417
} ,
365
-
366
418
moveVideoDown : function ( videoId , playlistItemId ) {
367
419
const playlistItems = [ ] . concat ( this . playlistItems )
368
420
const videoIndex = playlistItems . findIndex ( ( video ) => {
0 commit comments