Using default user prefixes when not provided by the ircd
authorDarren <darren@darrenwhitlen.com>
Wed, 2 Apr 2014 12:05:25 +0000 (13:05 +0100)
committerDarren <darren@darrenwhitlen.com>
Wed, 2 Apr 2014 12:05:25 +0000 (13:05 +0100)
client/src/models/member.js
client/src/models/network.js

index 588108dce8d05e7f3662eacf0da2a860a6ad3fcf..ce02f5e3a853e8ac5baf884238141ff8431651a8 100644 (file)
@@ -1,8 +1,10 @@
 _kiwi.model.Member = Backbone.Model.extend({\r
     sortModes: function (modes) {\r
+        var that = this;\r
+\r
         return modes.sort(function (a, b) {\r
             var a_idx, b_idx, i;\r
-            var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
+            var user_prefixes = that.get('user_prefixes');\r
 \r
             for (i = 0; i < user_prefixes.length; i++) {\r
                 if (user_prefixes[i].mode === a) {\r
@@ -65,7 +67,7 @@ _kiwi.model.Member = Backbone.Model.extend({
     },\r
     getPrefix: function (modes) {\r
         var prefix = '';\r
-        var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
+        var user_prefixes = this.get('user_prefixes');\r
 \r
         if (typeof modes[0] !== 'undefined') {\r
             prefix = _.detect(user_prefixes, function (prefix) {\r
@@ -77,7 +79,7 @@ _kiwi.model.Member = Backbone.Model.extend({
     },\r
     stripPrefix: function (nick) {\r
         var tmp = nick, i, j, k, nick_char;\r
-        var user_prefixes = _kiwi.gateway.get('user_prefixes');\r
+        var user_prefixes = this.get('user_prefixes');\r
         i = 0;\r
 \r
         nick_character_loop:\r
@@ -106,7 +108,7 @@ _kiwi.model.Member = Backbone.Model.extend({
         return display;\r
     },\r
     isOp: function () {\r
-        var user_prefixes = _kiwi.gateway.get('user_prefixes'),\r
+        var user_prefixes = this.get('user_prefixes'),\r
             modes = this.get('modes'),\r
             o, max_mode;\r
         if (modes.length > 0) {\r
index 0374d068d20aa490fc86b636868769622ba4770b..a0ba5475c104f23890cd595a17ed5a7b7b440c09 100644 (file)
         members = c.get('members');
         if (!members) return;
 
-        user = new _kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname});
+        user = new _kiwi.model.Member({
+            nick: event.nick,
+            ident: event.ident,
+            hostname: event.hostname,
+            user_prefixes: this.get('user_prefixes')
+        });
         members.add(user, {kiwi: event});
     }
 
 
 
     function onUserlist(event) {
-        var channel;
-        channel = this.panels.getByName(event.channel);
+        var that = this,
+            channel = this.panels.getByName(event.channel);
 
         // If we didn't find a channel for this, may aswell leave
         if (!channel) return;
 
         channel.temp_userlist = channel.temp_userlist || [];
         _.each(event.users, function (item) {
-            var user = new _kiwi.model.Member({nick: item.nick, modes: item.modes});
+            var user = new _kiwi.model.Member({
+                nick: item.nick,
+                modes: item.modes,
+                user_prefixes: that.get('user_prefixes')
+            });
             channel.temp_userlist.push(user);
         });
     }