Merge pull request #58 from maxpoulin64/userlist-lag
Only update the users list when needed
This commit is contained in:
commit
972aadd674
@ -395,6 +395,19 @@ $(function() {
|
||||
});
|
||||
|
||||
socket.on("users", function(data) {
|
||||
var chan = chat.find("#chan-" + data.chan);
|
||||
|
||||
if (chan.hasClass("active")) {
|
||||
socket.emit("names", {
|
||||
target: data.chan
|
||||
});
|
||||
}
|
||||
else {
|
||||
chan.data("needsNamesRefresh", true);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("names", function(data) {
|
||||
var users = chat.find("#chan-" + data.chan).find(".users").html(render("user", data));
|
||||
var nicks = [];
|
||||
for (var i in data.users) {
|
||||
@ -573,6 +586,11 @@ $(function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (chan.data("needsNamesRefresh") === true) {
|
||||
chan.data("needsNamesRefresh", false);
|
||||
socket.emit("names", {target: self.data("id")});
|
||||
}
|
||||
|
||||
if (screen.width > 768 && chan.hasClass("chan")) {
|
||||
input.focus();
|
||||
}
|
||||
|
@ -303,6 +303,19 @@ Client.prototype.sort = function(data) {
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype.names = function(data) {
|
||||
var client = this;
|
||||
var target = client.find(data.target);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
client.emit("names", {
|
||||
chan: target.chan.id,
|
||||
users: target.chan.users
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.quit = function() {
|
||||
var sockets = this.sockets.sockets;
|
||||
var room = sockets.adapter.rooms[this.id] || [];
|
||||
|
@ -21,8 +21,7 @@ module.exports = function(irc, network) {
|
||||
chan.users.push(new User({name: data.nick}));
|
||||
chan.sortUsers();
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
chan: chan.id
|
||||
});
|
||||
var self = false;
|
||||
if (data.nick.toLowerCase() === irc.me.toLowerCase()) {
|
||||
|
@ -19,8 +19,7 @@ module.exports = function(irc, network) {
|
||||
}
|
||||
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
chan: chan.id
|
||||
});
|
||||
|
||||
var self = false;
|
||||
|
@ -14,8 +14,7 @@ module.exports = function(irc, network) {
|
||||
});
|
||||
chan.sortUsers();
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
chan: chan.id
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -31,8 +31,7 @@ module.exports = function(irc, network) {
|
||||
user.name = nick;
|
||||
chan.sortUsers();
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
chan: chan.id
|
||||
});
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.NICK,
|
||||
|
@ -19,8 +19,7 @@ module.exports = function(irc, network) {
|
||||
var user = _.findWhere(chan.users, {name: from});
|
||||
chan.users = _.without(chan.users, user);
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
chan: chan.id
|
||||
});
|
||||
var reason = data.message || "";
|
||||
if (reason.length > 0) {
|
||||
|
@ -12,8 +12,7 @@ module.exports = function(irc, network) {
|
||||
}
|
||||
chan.users = _.without(chan.users, user);
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
chan: chan.id
|
||||
});
|
||||
var reason = data.message || "";
|
||||
if (reason.length > 0) {
|
||||
|
@ -121,6 +121,12 @@ function init(socket, client, token) {
|
||||
client.sort(data);
|
||||
}
|
||||
);
|
||||
socket.on(
|
||||
"names",
|
||||
function(data) {
|
||||
client.names(data);
|
||||
}
|
||||
);
|
||||
socket.join(client.id);
|
||||
socket.emit("init", {
|
||||
active: client.activeChannel,
|
||||
|
Loading…
Reference in New Issue
Block a user