From ef0344942bea9f3b7d818196135b810478b866d1 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Tue, 22 Apr 2025 01:42:07 -0400 Subject: [PATCH] Fixed refreshNextTimer so it clears out stale timers. --- src/app/channel/media/queue.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/channel/media/queue.js b/src/app/channel/media/queue.js index 8c8ae1d..7f677c5 100644 --- a/src/app/channel/media/queue.js +++ b/src/app/channel/media/queue.js @@ -283,6 +283,10 @@ module.exports = class{ //Get current item const currentItem = this.getItemAtEpoch() + + //Clear out any stale timers to prevent ghost queueing + clearTimeout(this.nextTimer); + //If we have a current item and it isn't currently playing if(currentItem != null && (this.nowPlaying == null || currentItem.uuid != this.nowPlaying.uuid)){ //Start the found item at w/ a pre-calculated time stamp to reflect the given start time @@ -292,8 +296,6 @@ module.exports = class{ //Calculate the amount of time in ms that the next item will start in const startsIn = nextItem.startTime - new Date().getTime(); - //Clear out any item that might be up next - clearTimeout(this.nextTimer); //Set the next timer this.nextTimer = setTimeout(()=>{this.start(nextItem, nextItem.startTimeStamp, volatile)}, startsIn); }