From fdab26b7921a928d00e332a2d1c8fe465063afa1 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Thu, 24 May 2018 23:49:28 -0700 Subject: [PATCH] Hoist sortUserlist outside of userlist population inner loop --- package.json | 2 +- www/js/callbacks.js | 25 +++---------------------- www/js/data.js | 1 + www/js/util.js | 24 ++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 003a910e..013b6a1d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.55.7", + "version": "3.55.8", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/www/js/callbacks.js b/www/js/callbacks.js index b2c6c4db..292ba31f 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -487,32 +487,13 @@ Callbacks = { userlist: function(data) { $(".userlist_item").remove(); for(var i = 0; i < data.length; i++) { - Callbacks.addUser(data[i]); + CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList(data[i]); } + sortUserlist(); }, addUser: function(data) { - var user = findUserlistItem(data.name); - // Remove previous instance of user, if there was one - if(user !== null) - user.remove(); - var div = $("
") - .addClass("userlist_item"); - var icon = $("").appendTo(div); - var nametag = $("").text(data.name).appendTo(div); - div.data("name", data.name); - div.data("rank", data.rank); - div.data("leader", Boolean(data.leader)); - div.data("profile", data.profile); - div.data("meta", data.meta); - if (data.meta.muted || data.meta.smuted) { - div.data("icon", "glyphicon-volume-off"); - } else { - div.data("icon", false); - } - formatUserlistItem(div); - addUserDropdown(div, data); - div.appendTo($("#userlist")); + CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList(data); sortUserlist(); }, diff --git a/www/js/data.js b/www/js/data.js index e71bfeb3..d759b038 100644 --- a/www/js/data.js +++ b/www/js/data.js @@ -76,6 +76,7 @@ CyTube.ui = { CyTube.featureFlag = { efficientEmotes: true }; +CyTube._internal_do_not_use_or_you_will_be_banned = {}; function getOpt(k) { var v = NO_STORAGE ? readCookie(k) : localStorage.getItem(k); diff --git a/www/js/util.js b/www/js/util.js index 69ee07e1..dc564307 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -3363,3 +3363,27 @@ CyTube.ui.changeVideoWidth = function uiChangeVideoWidth(direction) { handleVideoResize(); }; + +CyTube._internal_do_not_use_or_you_will_be_banned.addUserToList = function (data) { + var user = findUserlistItem(data.name); + // Remove previous instance of user, if there was one + if(user !== null) + user.remove(); + var div = $("
") + .addClass("userlist_item"); + var icon = $("").appendTo(div); + var nametag = $("").text(data.name).appendTo(div); + div.data("name", data.name); + div.data("rank", data.rank); + div.data("leader", Boolean(data.leader)); + div.data("profile", data.profile); + div.data("meta", data.meta); + if (data.meta.muted || data.meta.smuted) { + div.data("icon", "glyphicon-volume-off"); + } else { + div.data("icon", false); + } + formatUserlistItem(div); + addUserDropdown(div, data); + div.appendTo($("#userlist")); +};