From 2d3ef0b0510e4c0be49cb6025e312fcb932789fd Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Mon, 29 Jun 2015 15:20:49 -0400 Subject: @all and @channel now auto-complete --- web/react/components/mention.jsx | 2 +- web/react/components/mention_list.jsx | 15 ++++++++++++++- web/react/components/textbox.jsx | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'web/react/components') diff --git a/web/react/components/mention.jsx b/web/react/components/mention.jsx index 86a423138..f1292c743 100644 --- a/web/react/components/mention.jsx +++ b/web/react/components/mention.jsx @@ -9,7 +9,7 @@ module.exports = React.createClass({ return (
- @{this.props.username}{this.props.name} + @{this.props.username}{this.props.secondary_text}
); } diff --git a/web/react/components/mention_list.jsx b/web/react/components/mention_list.jsx index 8b7e25b04..eb21e0efe 100644 --- a/web/react/components/mention_list.jsx +++ b/web/react/components/mention_list.jsx @@ -74,6 +74,18 @@ module.exports = React.createClass({ users.push(profiles[id]); } + var all = {}; + all.username = "all"; + all.full_name = ""; + all.secondary_text = "Notifies everyone in the team"; + users.push(all); + + var channel = {}; + channel.username = "channel"; + channel.full_name = ""; + channel.secondary_text = "Notifies everyone in the channel"; + users.push(channel); + users.sort(function(a,b) { if (a.username < b.username) return -1; if (a.username > b.username) return 1; @@ -91,6 +103,7 @@ module.exports = React.createClass({ var splitName = users[i].full_name.split(' '); firstName = splitName[0].toLowerCase(); lastName = splitName.length > 1 ? splitName[splitName.length-1].toLowerCase() : ""; + users[i].secondary_text = users[i].full_name; } if (firstName.lastIndexOf(mentionText,0) === 0 @@ -99,7 +112,7 @@ module.exports = React.createClass({ ); diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index 7a4762e07..934e863a2 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -153,7 +153,7 @@ module.exports = React.createClass({ var mentions = []; for (var i = 0; i < matches.length; i++) { var m = matches[i].substring(1,matches[i].length).trim(); - if (m in profileMap && mentions.indexOf(m) === -1) { + if ((m in profileMap && mentions.indexOf(m) === -1) || Constants.SPECIAL_MENTIONS.indexOf(m) !== -1) { mentions.push(m); } } -- cgit v1.2.3-1-g7c22