From: Darren Date: Sun, 20 Apr 2014 21:27:42 +0000 (+0100) Subject: Remove view/output related data from member model X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cba6f47f1b7d53d84b718e103bd57bfe7eb4467f;p=KiwiIRC.git Remove view/output related data from member model --- diff --git a/client/src/helpers/utils.js b/client/src/helpers/utils.js index 5ccacb3..1779f6a 100644 --- a/client/src/helpers/utils.js +++ b/client/src/helpers/utils.js @@ -531,11 +531,11 @@ function styleText(string_id, params) { style = formatToIrcMsg(_kiwi.app.text_theme[string_id]); - // Bring member info back to first level of params + // Expand a member mask into its individual parts (nick, ident, hostname) if (params['%M']) { - _.each(params['%M'], function(val, key) { - params[key] = val; - }); + params['%N'] = params['%M'].nick; + params['%J'] = params['%M'].ident; + params['%H'] = params['%M'].hostname; } // Do the magic. Use the shorthand syntax to produce output. diff --git a/client/src/models/channel.js b/client/src/models/channel.js index 26f1433..93746ad 100644 --- a/client/src/models/channel.js +++ b/client/src/models/channel.js @@ -22,7 +22,7 @@ _kiwi.model.Channel = _kiwi.model.Panel.extend({ return; } - this.addMsg(' ', styleText('channel_join', {'%M': member.getMemberMask(), '%T': translateText('client_models_channel_join'), '%C': name}), 'action join', {time: options.kiwi.time}); + this.addMsg(' ', styleText('channel_join', {'%M': member.getMaskParts(), '%T': translateText('client_models_channel_join'), '%C': name}), 'action join', {time: options.kiwi.time}); }, this); members.bind("remove", function (member, members, options) { @@ -30,20 +30,20 @@ _kiwi.model.Channel = _kiwi.model.Panel.extend({ var msg = (options.kiwi.message) ? '(' + options.kiwi.message + ')' : ''; if (options.kiwi.type === 'quit' && show_message) { - this.addMsg(' ', styleText('channel_quit', {'%M': member.getMemberMask(), '%T': translateText('client_models_channel_quit', [msg]), '%C': name}), 'action quit', {time: options.kiwi.time}); + this.addMsg(' ', styleText('channel_quit', {'%M': member.getMaskParts(), '%T': translateText('client_models_channel_quit', [msg]), '%C': name}), 'action quit', {time: options.kiwi.time}); } else if (options.kiwi.type === 'kick') { if (!options.kiwi.current_user_kicked) { //If user kicked someone, show the message regardless of settings. if (show_message || options.kiwi.current_user_initiated) { - this.addMsg(' ', styleText('channel_kicked', {'%M': member.getMemberMask(), '%T': translateText('client_models_channel_kicked', [options.kiwi.by, msg]), '%C': name}), 'action kick', {time: options.kiwi.time}); + this.addMsg(' ', styleText('channel_kicked', {'%M': member.getMaskParts(), '%T': translateText('client_models_channel_kicked', [options.kiwi.by, msg]), '%C': name}), 'action kick', {time: options.kiwi.time}); } } else { this.addMsg(' ', styleText('channel_selfkick', {'%T': translateText('client_models_channel_selfkick', [options.kiwi.by, msg]), '%C': name}), 'action kick', {time: options.kiwi.time}); } } else if (show_message) { - this.addMsg(' ', styleText('channel_part', {'%M': member.getMemberMask(), '%T': translateText('client_models_channel_part', [msg]), '%C': name}), 'action part', {time: options.kiwi.time}); + this.addMsg(' ', styleText('channel_part', {'%M': member.getMaskParts(), '%T': translateText('client_models_channel_part', [msg]), '%C': name}), 'action part', {time: options.kiwi.time}); } }, this); diff --git a/client/src/models/member.js b/client/src/models/member.js index 88a4f45..7d65cee 100644 --- a/client/src/models/member.js +++ b/client/src/models/member.js @@ -148,9 +148,12 @@ _kiwi.model.Member = Backbone.Model.extend({ return display; }, - getMemberMask: function () { - // Why to use %N and %H is quite clear here. %J is because %I is already for italic and %U for underlines. Better ideas ? - return {'%N': this.get('nick'), '%J': this.get("ident"), '%H': this.get("hostname")}; + getMaskParts: function () { + return { + nick: this.get('nick') || '', + ident: this.get('ident') || '', + hostname: this.get('hostname') || '' + }; }, /** * With the modes set on the user, make note if we have some sort of op status