From a00820a4c6ff0c43d49d1fec2e87016103b4a341 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 21 May 2016 16:13:58 -0700 Subject: [PATCH] Fix queue progress bar for youtube playlists --- www/js/callbacks.js | 2 +- www/js/ui.js | 2 +- www/js/util.js | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 97fdd1c4..d3ed54b4 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -724,7 +724,7 @@ Callbacks = { queue: function(data) { PL_ACTION_QUEUE.queue(function (plq) { - stopQueueSpinner(data.item.media.id); + stopQueueSpinner(data.item.media); var li = makeQueueEntry(data.item, true); if (data.item.uid === PL_CURRENT) li.addClass("queue_active"); diff --git a/www/js/ui.js b/www/js/ui.js index c014a8db..955d1fa7 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -420,7 +420,7 @@ function queue(pos, src) { delete data.link; socket.emit("queue", data); - startQueueSpinner(data.id); + startQueueSpinner(data); if (emitQueue.length > 0) { notification.textContent = "Waiting to queue " + emitQueue[0].link; } else { diff --git a/www/js/util.js b/www/js/util.js index dcfe3d9b..0dbe5987 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -3041,11 +3041,16 @@ function showChannelSettings() { // There is a point where this file needed to stop and we have clearly passed // it but let's keep going and see what happens -function startQueueSpinner(id) { +function startQueueSpinner(data) { if ($("#queueprogress").length > 0) { return; } + var id = data.id; + if (data.type === "yp") { + id = "$any"; + } + var progress = $("
").addClass("progress").attr("id", "queueprogress") .data("queue-id", id); var progressBar = $("
").addClass("progress-bar progress-bar-striped active") @@ -3060,10 +3065,12 @@ function startQueueSpinner(id) { progress.appendTo($("#addfromurl")); } -function stopQueueSpinner(id) { - if (id && $("#queueprogress").data("queue-id") === id) { - $("#queueprogress").remove(); - } else if (id === null) { +function stopQueueSpinner(data) { + var shouldRemove = (typeof data === 'object' && + $("#queueprogress").data("queue-id") === data.id); + shouldRemove = shouldRemove || data === null; + shouldRemove = shouldRemove || $("#queueprogress").data("queue-id") === "$any"; + if (shouldRemove) { $("#queueprogress").remove(); } }