Check if user exists before adding to memberlist
authorDarren <darren@darrenwhitlen.com>
Sun, 19 Oct 2014 14:26:44 +0000 (15:26 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 19 Oct 2014 14:26:44 +0000 (15:26 +0100)
client/src/models/network.js
client/src/views/channel.js

index c09abe291ac038a09a41e2f66b494bf497b99ea3..70b8fecf07d9450a69066ee0a50b812719e45dae 100644 (file)
         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,
index 61cb1b7768fc85a22a5ca7b6019d73c1c6009c5a..af132165dd4510687d4c1e1e93a1e257d74d63d8 100644 (file)
@@ -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)