From 5a0eb99729bd66102bd75a7199a64766cb16cc9a Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 19 Oct 2014 15:26:44 +0100 Subject: [PATCH] Check if user exists before adding to memberlist --- client/src/models/network.js | 5 +++++ client/src/views/channel.js | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/client/src/models/network.js b/client/src/models/network.js index c09abe2..70b8fec 100644 --- a/client/src/models/network.js +++ b/client/src/models/network.js @@ -331,6 +331,11 @@ members = c.get('members'); if (!members) return; + // Do we already have this member? + if (members.getByNick(event.nick)) { + return; + } + user = new _kiwi.model.Member({ nick: event.nick, ident: event.ident, diff --git a/client/src/views/channel.js b/client/src/views/channel.js index 61cb1b7..af13216 100644 --- a/client/src/views/channel.js +++ b/client/src/views/channel.js @@ -26,6 +26,7 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({ this.model.bind('change:topic_set_by', this.topicSetBy, this); if (this.model.get('members')) { + // When we join the memberlist, we have officially joined the channel this.model.get('members').bind('add', function (member) { if (member.get('nick') === this.model.collection.network.get('nick')) { this.$el.find('.initial_loader').slideUp(function () { @@ -33,6 +34,15 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({ }); } }, this); + + // Memberlist reset with a new nicklist? Consider we have joined + this.model.get('members').bind('reset', function(members) { + if (members.getByNick(this.model.collection.network.get('nick'))) { + this.$el.find('.initial_loader').slideUp(function () { + $(this).remove(); + }); + } + }, this); } // Only show the loader if this is a channel (ie. not a query) -- 2.25.1