Fix queue progress bar for youtube playlists

This commit is contained in:
calzoneman 2016-05-21 16:13:58 -07:00
parent 75245e4d98
commit a00820a4c6
3 changed files with 14 additions and 7 deletions

View File

@ -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");

View File

@ -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 {

View File

@ -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 = $("<div/>").addClass("progress").attr("id", "queueprogress")
.data("queue-id", id);
var progressBar = $("<div/>").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();
}
}