@all and @channel now auto-complete

This commit is contained in:
JoramWilander
2015-06-29 15:20:49 -04:00
parent 7b7e73fb92
commit 2d3ef0b051
4 changed files with 17 additions and 3 deletions

View File

@@ -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>
);
}

View File

@@ -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} />
);

View File

@@ -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);
}
}

View File

@@ -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'],