Gracefully allow script authors time to update their code

This commit is contained in:
Xaekai 2017-06-15 22:09:09 -07:00
parent df0fc769d9
commit f89832a6d1
3 changed files with 20 additions and 17 deletions

View File

@ -418,8 +418,10 @@ Channel.prototype.acceptUser = function (user) {
user.socket.emit("channelNotRegistered");
}
user.on('afk', function(){
user.on('afk', function(afk){
self.sendUserMeta(self.users, user, -1);
// TODO: Drop legacy setAFK frame after a few months
self.broadcastAll("setAFK", { name: user.getName(), afk: afk });
})
};

View File

@ -507,13 +507,12 @@ Callbacks = {
div.data("leader", Boolean(data.leader));
div.data("profile", data.profile);
div.data("meta", data.meta);
div.data("afk", data.meta.afk);
if (data.meta.muted || data.meta.smuted) {
div.data("icon", "glyphicon-volume-off");
} else {
div.data("icon", false);
}
formatUserlistItem(div, data);
formatUserlistItem(div);
addUserDropdown(div, data);
div.appendTo($("#userlist"));
sortUserlist();
@ -532,11 +531,24 @@ Callbacks = {
user.data("icon", false);
}
/*
* 2017-06-15
* TODO: Remove this and the empty function below
* after script authors have had ample time to update
*/
socket.listeners('setAFK').forEach(function(listener){
listener(data.meta.afk);
});
formatUserlistItem(user, data);
addUserDropdown(user, data);
sortUserlist();
},
setAFK: function() {
return true;
},
setUserProfile: function (data) {
var user = findUserlistItem(data.name);
if (user === null)
@ -627,16 +639,6 @@ Callbacks = {
formatUserlistItem(user);
},
setAFK: function (data) {
var user = findUserlistItem(data.name);
if(user === null)
return;
user.data("afk", data.afk);
formatUserlistItem(user);
if(USEROPTS.sort_afk)
sortUserlist();
},
userLeave: function(data) {
var user = findUserlistItem(data.name);
if(user !== null)

View File

@ -87,7 +87,6 @@ function formatUserlistItem(div) {
profile: div.data("profile") || { image: "", text: ""},
leader: div.data("leader") || false,
icon: div.data("icon") || false,
afk: div.data("afk") || false
};
var name = $(div.children()[1]);
name.removeClass();
@ -95,7 +94,7 @@ function formatUserlistItem(div) {
name.addClass(getNameColor(data.rank));
div.find(".profile-box").remove();
if (data.afk) {
if (div.data("meta") && div.data().meta.afk) {
div.addClass("userlist_afk");
} else {
div.removeClass("userlist_afk");
@ -173,7 +172,7 @@ function formatUserlistItem(div) {
if(data.leader) {
$("<span/>").addClass("glyphicon glyphicon-star-empty").appendTo(icon);
}
if(data.afk) {
if(div.data().meta.afk) {
name.css("font-style", "italic");
$("<span/>").addClass("glyphicon glyphicon-time").appendTo(icon);
}
@ -398,7 +397,7 @@ function calcUserBreakdown() {
total++;
if($(item).data("afk"))
if($(item).data().meta.afk)
breakdown["AFK"]++;
});