Finished up with Playlist Managment UI.

This commit is contained in:
rainbow napkin 2025-04-04 08:18:20 -04:00
parent c8c59feb7f
commit f21b66fae0
7 changed files with 180 additions and 42 deletions

View file

@ -606,6 +606,17 @@ channelSchema.methods.deletePlaylistByName = async function(name){
await this.save();
}
channelSchema.methods.deletePlaylistMediaByUUID = async function(name, uuid){
//Find the playlist
let playlist = this.getPlaylistByName(name);
//splice out the given playlist
this.media.playlists[playlist.listIndex].deleteMedia(uuid);
//save the channel document
await this.save();
}
channelSchema.methods.addToPlaylist = async function(name, media){
//Find the playlist
let playlist = this.getPlaylistByName(name);

View file

@ -52,4 +52,21 @@ playlistSchema.methods.dehydrate = function(){
}
}
playlistSchema.methods.deleteMedia = function(uuid){
//Create new array to hold list of media to be kept
const keptMedia = [];
//For every piece of media in the current playlist
for(let media of this.media){
//It isn't the media to be deleted
if(media.uuid.toString() != uuid){
//Add it to the list to be kept
keptMedia.push(media);
}
}
//Set playlist media from keptMedia
this.media = keptMedia;
}
module.exports = playlistSchema;