diff --git a/user.js b/user.js index ba946344..c251a327 100644 --- a/user.js +++ b/user.js @@ -83,7 +83,8 @@ User.prototype.noflood = function(name, hz) { User.prototype.setAFK = function (afk) { if(this.channel === null) return; - var changed = this.meta.afk != afk; + if(this.meta.afk === afk) + return; var chan = this.channel; this.meta.afk = afk; if(afk) { @@ -96,7 +97,10 @@ User.prototype.setAFK = function (afk) { this.autoAFK(); } chan.checkVoteskipPass(); - chan.broadcastUserUpdate(this); + chan.sendAll("setAFK", { + name: this.name, + afk: afk + }); } User.prototype.autoAFK = function () { diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index ee64c7bb..f5ae5fc2 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -660,6 +660,24 @@ Callbacks = { }, + setAFK: function (data) { + var users = $("#userlist").children(); + for(var i = 0; i < users.length; i++) { + var name = users[i].children[1].innerHTML; + // Reformat user + if(name == data.name) { + var u = $(users[i]); + u.find(".icon-time").remove(); + $(users[i].children[1]).css("font-style", ""); + if(data.afk) { + $("").addClass("icon-time") + .appendTo(users[i].children[0]); + $(users[i].children[1]).css("font-style", ""); + } + } + } + }, + userLeave: function(data) { var users = $("#userlist").children(); for(var i = 0; i < users.length; i++) {