Tweak ACL behaviour

ACL is only updated when you first join, when someone's rank changes, or if
you click the Channel Ranks tab
This commit is contained in:
calzoneman 2013-04-23 13:47:09 -05:00
parent ce84b30354
commit 3f5ec309e9
3 changed files with 12 additions and 4 deletions

View File

@ -388,6 +388,10 @@ Channel.prototype.sendRankStuff = function(user) {
} }
user.socket.emit("chatFilters", {filters: filts}); user.socket.emit("chatFilters", {filters: filts});
} }
this.sendACL(user);
}
Channel.prototype.sendACL = function(user) {
if(Rank.hasPermission(user, "acl")) { if(Rank.hasPermission(user, "acl")) {
user.socket.emit("acl", Database.getChannelRanks(this.name)); user.socket.emit("acl", Database.getChannelRanks(this.name));
} }
@ -453,7 +457,6 @@ Channel.prototype.broadcastNewUser = function(user) {
this.sendRankStuff(user); this.sendRankStuff(user);
if(user.rank > Rank.Guest) { if(user.rank > Rank.Guest) {
this.saveRank(user); this.saveRank(user);
this.broadcastRankTable();
} }
} }
@ -504,9 +507,7 @@ Channel.prototype.broadcastBanlist = function() {
Channel.prototype.broadcastRankTable = function() { Channel.prototype.broadcastRankTable = function() {
var ranks = Database.getChannelRanks(this.name); var ranks = Database.getChannelRanks(this.name);
for(var i = 0; i < this.users.length; i++) { for(var i = 0; i < this.users.length; i++) {
if(Rank.hasPermission(this.users[i], "acl")) { this.sendACL(this.users[i]);
this.users[i].socket.emit("acl", ranks);
}
} }
} }

View File

@ -255,6 +255,12 @@ User.prototype.initCallbacks = function() {
} }
}.bind(this)); }.bind(this));
this.socket.on("requestAcl", function() {
if(this.channel != null) {
this.channel.sendACL(this);
}
}.bind(this));
this.socket.on("voteskip", function(data) { this.socket.on("voteskip", function(data) {
if(this.channel != null) { if(this.channel != null) {
this.channel.tryVoteskip(this); this.channel.tryVoteskip(this);

View File

@ -432,6 +432,7 @@ $("#show_acl").click(function() {
$(".modonly").hide(); $(".modonly").hide();
$("#show_acl").parent().addClass("active"); $("#show_acl").parent().addClass("active");
$("#channelranks").show(); $("#channelranks").show();
socket.emit("requestAcl");
}); });
function searchLibrary() { function searchLibrary() {