From 0addff6bab321e4d7d05a6e99483cc8aa2cf9395 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 23 Sep 2013 16:25:45 -0500 Subject: [PATCH] Don't add delete buttons to youtube search results People kept clicking them resulting in database errors for unregistered channels. --- changelog | 9 +++++++++ lib/user.js | 2 ++ www/assets/js/callbacks.js | 7 +------ www/assets/js/util.js | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/changelog b/changelog index 66d2143d..e97c1fae 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,12 @@ +Mon Sep 23 16:22 2013 CDT + * lib/user.js: distinguish search result return packets with a 'source' + field that specifies where the item came from (e.g 'yt' for youtube + search, 'library' for library search) + * www/assets/js/callbacks.js: account for the change in lib/user.js + which adds a 'source' field to library search results + * www/assets/js/util.js: don't add delete buttons for youtube search + results. Apparently people keep clicking them... + Sat Sep 21 23:53 2013 CDT * lib/playlist.js, www/assets/js/player.js: Modify the server lead function to have a 3 second lead-in period (to allow buffering). diff --git a/lib/user.js b/lib/user.js index 0acfdb6a..b31baca4 100644 --- a/lib/user.js +++ b/lib/user.js @@ -326,6 +326,7 @@ User.prototype.initCallbacks = function() { searchfn(data.query.split(" "), function (e, vids) { if(!e) { self.socket.emit("searchResults", { + source: "yt", results: vids }); } @@ -333,6 +334,7 @@ User.prototype.initCallbacks = function() { } else { self.channel.search(data.query, function (vids) { self.socket.emit("searchResults", { + source: "library", results: vids }); }); diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 65ec4248..4582c07a 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -953,12 +953,7 @@ Callbacks = { generator: function (item, page, index) { var li = makeSearchEntry(item, false); if(hasPermission("playlistadd")) { - if(item.thumb) { - addLibraryButtons(li, item.id, "yt"); - } - else { - addLibraryButtons(li, item.id); - } + addLibraryButtons(li, item.id, data.source); } $(li).appendTo($("#library")); }, diff --git a/www/assets/js/util.js b/www/assets/js/util.js index a4cad014..f2a21ef6 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -1143,11 +1143,13 @@ function clearSearchResults() { } } -function addLibraryButtons(li, id, type) { +function addLibraryButtons(li, id, source) { var btns = $("
").addClass("btn-group") .addClass("pull-left") .prependTo(li); + var type = (source === "library") ? undefined : source; + if(hasPermission("playlistadd")) { if(hasPermission("playlistnext")) { $("