Client: showing nick changes; Updating tab name on nick change
authorDarren <darren@Darrens-MacBook-Pro.local>
Sat, 4 May 2013 15:03:54 +0000 (16:03 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Sat, 4 May 2013 15:03:54 +0000 (16:03 +0100)
client/assets/dev/model_network.js
client/assets/dev/view.js

index aa35f007b5efbab748b3d88493601cf231b6a4b0..c21f5e896292a0b7f792e71f6676dcdee342f5f2 100644 (file)
@@ -68,6 +68,7 @@
             this.gateway.on('quit', onQuit, this);
             this.gateway.on('kick', onKick, this);
             this.gateway.on('msg', onMsg, this);
+            this.gateway.on('nick', onNick, this);
             this.gateway.on('ctcp_request', onCtcpRequest, this);
             this.gateway.on('ctcp_response', onCtcpResponse, this);
             this.gateway.on('notice', onNotice, this);
 
 
 
+    function onNick(event) {
+        var member;
+
+        $.each(this.panels.models, function (index, panel) {
+            if (panel.get('name') == event.nick)
+                panel.set('name', event.newnick);
+
+            if (!panel.isChannel()) return;
+
+            member = panel.get('members').getByNick(event.nick);
+            if (member) {
+                member.set('nick', event.newnick);
+                panel.addMsg('', '== ' + event.nick + ' is now known as ' + event.newnick, 'action nick');
+            }
+        });
+    }
+
+
+
     function onCtcpRequest(event) {
         // An ignored user? don't do anything with it
         if (_kiwi.gateway.isNickIgnored(event.nick)) {
index feccd448655c380f12e1b1fb78bcb1adbdc526d2..383a2c512ba3311c7563b84d332cb434f9dad431 100644 (file)
@@ -800,6 +800,8 @@ _kiwi.view.Tabs = Backbone.View.extend({
         panel.tab.appendTo(this.$el);\r
 \r
         panel.bind('change:title', this.updateTabTitle);\r
+        panel.bind('change:name', this.updateTabTitle);\r
+\r
         _kiwi.app.view.doLayout();\r
     },\r
     panelRemoved: function (panel) {\r