From: Darren Date: Wed, 2 Apr 2014 12:05:25 +0000 (+0100) Subject: Using default user prefixes when not provided by the ircd X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=11412289aafa3f6dc1a3212494f9304037e3e456;p=KiwiIRC.git Using default user prefixes when not provided by the ircd --- diff --git a/client/src/models/member.js b/client/src/models/member.js index 588108d..ce02f5e 100644 --- a/client/src/models/member.js +++ b/client/src/models/member.js @@ -1,8 +1,10 @@ _kiwi.model.Member = Backbone.Model.extend({ sortModes: function (modes) { + var that = this; + return modes.sort(function (a, b) { var a_idx, b_idx, i; - var user_prefixes = _kiwi.gateway.get('user_prefixes'); + var user_prefixes = that.get('user_prefixes'); for (i = 0; i < user_prefixes.length; i++) { if (user_prefixes[i].mode === a) { @@ -65,7 +67,7 @@ _kiwi.model.Member = Backbone.Model.extend({ }, getPrefix: function (modes) { var prefix = ''; - var user_prefixes = _kiwi.gateway.get('user_prefixes'); + var user_prefixes = this.get('user_prefixes'); if (typeof modes[0] !== 'undefined') { prefix = _.detect(user_prefixes, function (prefix) { @@ -77,7 +79,7 @@ _kiwi.model.Member = Backbone.Model.extend({ }, stripPrefix: function (nick) { var tmp = nick, i, j, k, nick_char; - var user_prefixes = _kiwi.gateway.get('user_prefixes'); + var user_prefixes = this.get('user_prefixes'); i = 0; nick_character_loop: @@ -106,7 +108,7 @@ _kiwi.model.Member = Backbone.Model.extend({ return display; }, isOp: function () { - var user_prefixes = _kiwi.gateway.get('user_prefixes'), + var user_prefixes = this.get('user_prefixes'), modes = this.get('modes'), o, max_mode; if (modes.length > 0) { diff --git a/client/src/models/network.js b/client/src/models/network.js index 0374d06..a0ba547 100644 --- a/client/src/models/network.js +++ b/client/src/models/network.js @@ -302,7 +302,12 @@ 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}); } @@ -575,15 +580,19 @@ 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); }); }