From 079538d9e7d22cd8d5f782f4f7434858bd80d914 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 13 Jul 2015 15:39:53 -0400 Subject: Use User.FirstName for notifications instead of trying to determine it from User.Nickname --- web/react/components/mention_list.jsx | 14 +++----------- web/react/components/user_settings.jsx | 23 +++++++---------------- web/react/stores/user_store.jsx | 6 +----- 3 files changed, 11 insertions(+), 32 deletions(-) (limited to 'web') diff --git a/web/react/components/mention_list.jsx b/web/react/components/mention_list.jsx index c04e28849..524f1b337 100644 --- a/web/react/components/mention_list.jsx +++ b/web/react/components/mention_list.jsx @@ -188,21 +188,13 @@ module.exports = React.createClass({ for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) { if (this.alreadyMentioned(users[i].username)) continue; - var firstName = "", lastName = ""; - if (users[i].nickname.length > 0) { - var splitName = users[i].nickname.split(' '); - firstName = splitName[0].toLowerCase(); - lastName = splitName.length > 1 ? splitName[splitName.length-1].toLowerCase() : ""; - users[i].secondary_text = users[i].nickname; - } - - if (firstName.lastIndexOf(mentionText,0) === 0 - || lastName.lastIndexOf(mentionText,0) === 0 || users[i].username.lastIndexOf(mentionText,0) === 0) { + if (users[i].first_name.lastIndexOf(mentionText,0) === 0 + || users[i].last_name.lastIndexOf(mentionText,0) === 0 || users[i].username.lastIndexOf(mentionText,0) === 0) { mentions[index] = ( 0) { - first_name = user.nickname.split(' ')[0]; - } - var inputs = []; - if (first_name != "") { + if (user.first_name) { inputs.push(
@@ -396,14 +392,9 @@ var NotificationsTab = React.createClass({ ); } else { var keys = []; - if (this.state.first_name_key) { - var first_name = ""; - var user = this.props.user; - if (user.nickname.length > 0) first_name = user.nickname.split(' ')[0]; - if (first_name != "") keys.push(first_name); - } - if (this.state.username_key) keys.push(this.props.user.username); - if (this.state.mention_key) keys.push('@'+this.props.user.username); + if (this.state.first_name_key) keys.push(user.first_name); + if (this.state.username_key) keys.push(user.username); + if (this.state.mention_key) keys.push('@'+user.username); if (this.state.all_key) keys.push('@all'); if (this.state.channel_key) keys.push('@channel'); if (this.state.custom_keys.length > 0) keys = keys.concat(this.state.custom_keys.split(',')); diff --git a/web/react/stores/user_store.jsx b/web/react/stores/user_store.jsx index c293469e5..e417e72ff 100644 --- a/web/react/stores/user_store.jsx +++ b/web/react/stores/user_store.jsx @@ -180,11 +180,7 @@ var UserStore = assign({}, EventEmitter.prototype, { if (user && user.notify_props && user.notify_props.mention_keys) { var keys = user.notify_props.mention_keys.split(','); - if (user.nickname.length > 0 && user.notify_props.first_name === "true") { - var first = user.nickname.split(' ')[0]; - if (first.length > 0) keys.push(first); - } - + if (user.first_name && user.notify_props.first_name === "true") keys.push(user.first_name); if (user.notify_props.all === "true") keys.push('@all'); if (user.notify_props.channel === "true") keys.push('@channel'); -- cgit v1.2.3-1-g7c22