From 75245e4d98df9bfe8c2c1aa6cca5b8e4f6542699 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 19 May 2016 21:31:10 -0700 Subject: [PATCH] Include video ID in the progress bar to prevent false clears --- src/channel/playlist.js | 24 ++++++++++++++++-------- www/js/callbacks.js | 8 +++++--- www/js/ui.js | 2 +- www/js/util.js | 13 +++++++++---- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/channel/playlist.js b/src/channel/playlist.js index 82e7eb6e..6a023f71 100644 --- a/src/channel/playlist.js +++ b/src/channel/playlist.js @@ -361,25 +361,29 @@ PlaylistModule.prototype.handleQueue = function (user, data) { if (data.type === "yp" && !perms.canAddList(user)) { user.socket.emit("queueFail", { msg: "You don't have permission to add playlists", - link: link + link: link, + id: id }); return; } else if (util.isLive(type) && !perms.canAddLive(user)) { user.socket.emit("queueFail", { msg: "You don't have permission to add live media", - link: link + link: link, + id: id }); return; } else if (type === "cu" && !perms.canAddCustom(user)) { user.socket.emit("queueFail", { msg: "You don't have permission to add custom embeds", - link: link + link: link, + id: id }); return; } else if (type === "fi" && !perms.canAddRawFile(user)) { user.socket.emit("queueFail", { msg: "You don't have permission to add raw video files", - link: link + link: link, + id: id }); return; } @@ -412,7 +416,8 @@ PlaylistModule.prototype.handleQueue = function (user, data) { if (user.queueLimiter.throttle(limit)) { user.socket.emit("queueFail", { msg: "You are adding videos too quickly", - link: link + link: link, + id: id }); return; } @@ -448,7 +453,8 @@ PlaylistModule.prototype.queueStandard = function (user, data) { var error = function (what) { user.socket.emit("queueFail", { msg: what, - link: data.link + link: data.link, + id: data.id }); }; @@ -501,7 +507,8 @@ PlaylistModule.prototype.queueYouTubePlaylist = function (user, data) { var error = function (what) { user.socket.emit("queueFail", { msg: what, - link: data.link + link: data.link, + id: data.id }); }; @@ -865,7 +872,8 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) { var qfail = function (msg) { user.socket.emit("queueFail", { msg: msg, - link: data.link + link: data.link, + id: data.id }); if (cb) { cb(); diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 16154743..97fdd1c4 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -25,7 +25,7 @@ Callbacks = { .text("Connected") .appendTo($("#messagebuffer")); scrollChat(); - stopQueueSpinner(); + stopQueueSpinner(null); }, disconnect: function() { @@ -724,7 +724,7 @@ Callbacks = { queue: function(data) { PL_ACTION_QUEUE.queue(function (plq) { - stopQueueSpinner(); + stopQueueSpinner(data.item.media.id); var li = makeQueueEntry(data.item, true); if (data.item.uid === PL_CURRENT) li.addClass("queue_active"); @@ -762,7 +762,9 @@ Callbacks = { }, queueFail: function (data) { - stopQueueSpinner(); + if (data.id) { + stopQueueSpinner(id); + } queueMessage(data, "alert-danger"); }, diff --git a/www/js/ui.js b/www/js/ui.js index 5646f4bd..c014a8db 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(); + startQueueSpinner(data.id); 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 a4d21812..dcfe3d9b 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -3041,12 +3041,13 @@ 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() { +function startQueueSpinner(id) { if ($("#queueprogress").length > 0) { return; } - var progress = $("
").addClass("progress").attr("id", "queueprogress"); + var progress = $("
").addClass("progress").attr("id", "queueprogress") + .data("queue-id", id); var progressBar = $("
").addClass("progress-bar progress-bar-striped active") .attr({ role: "progressbar", @@ -3059,6 +3060,10 @@ function startQueueSpinner() { progress.appendTo($("#addfromurl")); } -function stopQueueSpinner() { - $("#queueprogress").remove(); +function stopQueueSpinner(id) { + if (id && $("#queueprogress").data("queue-id") === id) { + $("#queueprogress").remove(); + } else if (id === null) { + $("#queueprogress").remove(); + } }