Moving currently playing items to an invalid spot in the schedule no longer creates ghost items.
This commit is contained in:
parent
a1f0824330
commit
349a6b82aa
|
|
@ -642,6 +642,8 @@ class queue{
|
|||
|
||||
//Find our media, don't remove it yet since we want to do some more testing first
|
||||
let media = this.getItemByUUID(uuid);
|
||||
//Create value to hold old media in-case somethin' fucks up
|
||||
let oldMedia = null;
|
||||
|
||||
//If we got a bad request
|
||||
if(media == null){
|
||||
|
|
@ -658,6 +660,8 @@ class queue{
|
|||
if(media.startTime < new Date().getTime()){
|
||||
//If the item is currently playing
|
||||
if(media.getEndTime() > new Date().getTime()){
|
||||
//Set old media
|
||||
oldMedia = media;
|
||||
//Dupe media for the rest of the function
|
||||
media = media.clone();
|
||||
|
||||
|
|
@ -699,6 +703,13 @@ class queue{
|
|||
//Reset the start time stamp for re-calculation
|
||||
media.startTimeStamp = 0;
|
||||
|
||||
//If there's a cut-off from moving a now-playing item
|
||||
if(oldMedia != null){
|
||||
//Remove it from the queue to prevent ghost items
|
||||
this.removeMedia(oldMedia.uuid, socket, chanDB, true);
|
||||
}
|
||||
|
||||
|
||||
//Schedule in old slot with noSave enabled
|
||||
await this.scheduleMedia([media], socket, chanDB, true);
|
||||
}
|
||||
|
|
@ -721,7 +732,7 @@ class queue{
|
|||
* @param {String} uuid - UUID of item to reschedule
|
||||
* @param {Socket} socket - Requesting Socket
|
||||
* @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access
|
||||
* @param {Boolean} noScheduling - Disables schedule timer refresh if true
|
||||
* @param {Boolean} noScheduling - Disables schedule timer refresh and this.save() calls if true, good for internal function calls
|
||||
* @returns {Media} Deleted Media Item
|
||||
*/
|
||||
async removeMedia(uuid, socket, chanDB, noScheduling = false){
|
||||
|
|
@ -773,9 +784,13 @@ class queue{
|
|||
}else{
|
||||
//Broadcast changes
|
||||
this.broadcastQueue(chanDB);
|
||||
|
||||
//If saving is disabled
|
||||
if(!noScheduling){
|
||||
//Save changes to the DB
|
||||
await chanDB.save();
|
||||
}
|
||||
}
|
||||
}catch(err){
|
||||
//If this was originated by someone
|
||||
if(socket != null){
|
||||
|
|
|
|||
Loading…
Reference in a new issue