Updating member lists and user nick on nick changes
authorDarren <darren@darrenwhitlen.com>
Sat, 25 Aug 2012 20:31:25 +0000 (21:31 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 25 Aug 2012 20:31:25 +0000 (21:31 +0100)
client_backbone/model_application.js
client_backbone/model_gateway.js

index 080537ca25123c459b939b63fc53f8039b1bc4a8..ea6130d8ff5502874b937bc514a0551b11036d6e 100644 (file)
@@ -191,7 +191,21 @@ kiwi.model.Application = Backbone.Model.extend(new (function () {
             } else if (event.mode[0] === '-') {\r
                 member.removeMode(event.mode.substr(1));\r
             }\r
+        });\r
+\r
+\r
+        gw.on('onnick', function (event) {\r
+            var member;\r
 \r
+            $.each(that.panels.models, function (index, panel) {\r
+                if (!panel.isChannel()) return;\r
+\r
+                member = panel.get('members').getByNick(event.nick);\r
+                if (member) {\r
+                    member.set('nick', event.newnick);\r
+                    panel.addMsg('', '== ' + event.nick + ' is now known as ' + event.newnick, 'action nick');\r
+                }\r
+            });\r
         });\r
     };\r
 \r
index 52cf62fe3e61e789cb6a6bcfb94baf970163028c..dca83b3ea82699fc60cb6e659a19aa1c90cc037b 100644 (file)
@@ -170,7 +170,9 @@ kiwi.model.Gateway = Backbone.Model.extend(new (function () {
                 break;\r
 \r
             case 'nick':\r
-                that.set('nick', item.newnick);\r
+                if (item.nick === that.get('nick')) {\r
+                    that.set('nick', item.newnick);\r
+                }\r
                 break;\r
             /*\r
             case 'sync':\r