Fixed issues with NICK events

This commit is contained in:
Mattias Erming 2014-03-15 02:19:50 +01:00
parent aa40319ee9
commit 158abd7526
2 changed files with 28 additions and 13 deletions

View File

@ -160,7 +160,7 @@ $(function() {
};
$.fn.scrollToBottom = function() {
this.scrollTop(1e10);
this.scrollTop(this.prop("scrollHeight"));
};
$.fn.isScrollAtBottom = function() {

View File

@ -362,22 +362,29 @@ function handleEvent(argv) {
break;
case "NICK":
var message = new models.Message({
channels.each(function(channel) {
var users = channel.get("users");
var messages = channel.get("messages");
var user = users.findWhere({name: argv.nick});
if (typeof user !== "undefined") {
user.set("name", argv.args[0]);
users.sort();
users.trigger(
"change", {}, users
);
messages.add(new models.Message({
user: argv.nick,
text: "changed name to " + argv.args[0],
type: "nick"
});
channels.each(function(channel) {
var user = channel.get("users").findWhere({name: argv.nick});
if (typeof user !== "undefined") {
user.set("name", argv.args[0]);
channel.get("messages").add(message);
}));
}
});
if (argv.nick == network.get("nick")) {
network.set("nick", argv.args[0]);
network.set({nick: argv.args[0]}, {silent: true});
}
break;
@ -491,14 +498,21 @@ function handleEvent(argv) {
if (typeof rpl_namreply === "undefined") {
channel.get("users").reset({silent: true});
}
// This variable is global but will be deleted when
// rpl_endofnames is triggered..
rpl_namreply = true;
var names = argv.args[3].split(' ');
for (var i in names) {
var mode = (names[i].match(/^\W/) || "").toString();
var user = new models.User({
mode: mode,
name: names[i].replace(mode, '')
});
users.add(
new models.User({name: names[i]}), {
silent: true
}
user,
{silent: true}
);
}
break;
@ -507,6 +521,7 @@ function handleEvent(argv) {
var channel = channels.findWhere({name: argv.args[1]});
var users = channel.get("users");
// .. here!
delete rpl_namreply;
users.trigger(
"add", {}, users