summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-06-29 15:20:49 -0400
committerJoramWilander <jwawilander@gmail.com>2015-06-29 15:20:49 -0400
commit2d3ef0b0510e4c0be49cb6025e312fcb932789fd (patch)
tree0d639af3121043c69f6178bde3a50cf93c942140
parent7b7e73fb9290a8084989a4219681c636670e7555 (diff)
downloadchat-2d3ef0b0510e4c0be49cb6025e312fcb932789fd.tar.gz
chat-2d3ef0b0510e4c0be49cb6025e312fcb932789fd.tar.bz2
chat-2d3ef0b0510e4c0be49cb6025e312fcb932789fd.zip
@all and @channel now auto-complete
-rw-r--r--web/react/components/mention.jsx2
-rw-r--r--web/react/components/mention_list.jsx15
-rw-r--r--web/react/components/textbox.jsx2
-rw-r--r--web/react/utils/constants.jsx1
4 files changed, 17 insertions, 3 deletions
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 (
<div className="mentions-name" onClick={this.handleClick}>
<img className="mention-img" src={"/api/v1/users/" + this.props.id + "/image"}/>
- <span>@{this.props.username}</span><span className="mention-fullname">{this.props.name}</span>
+ <span>@{this.props.username}</span><span className="mention-fullname">{this.props.secondary_text}</span>
</div>
);
}
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({
<Mention
ref={'mention' + index}
username={users[i].username}
- name={users[i].full_name}
+ secondary_text={users[i].secondary_text}
id={users[i].id}
handleClick={this.handleClick} />
);
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);
}
}
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index e5f42c8a0..f3f3399d9 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -36,6 +36,7 @@ module.exports = {
SERVER_ACTION: null,
VIEW_ACTION: null
}),
+ SPECIAL_MENTIONS: ['all', 'channel'],
CHARACTER_LIMIT: 4000,
IMAGE_TYPES: ['jpg', 'gif', 'bmp', 'png'],
AUDIO_TYPES: ['mp3', 'wav', 'wma', 'm4a', 'flac', 'aac'],