composebox_typeahead: Optimize token identification.

This commit is contained in:
Yago González 2017-06-22 23:40:44 +02:00 committed by showell
parent e76c9f1200
commit c348b907e7
1 changed files with 6 additions and 5 deletions

View File

@ -287,13 +287,13 @@ exports.compose_content_begins_typeahead = function (query) {
return false;
}
current_token = q.substring(q.lastIndexOf('@') + 1);
current_token = current_token.substring(1);
if (current_token.length < 1 || current_token.lastIndexOf('*') !== -1) {
return false;
}
this.completing = 'mention';
this.token = current_token.substring(current_token.indexOf("@") + 1);
this.token = current_token;
var all_item = {
special_item_text: "all (Notify everyone)",
email: "all",
@ -317,18 +317,19 @@ exports.compose_content_begins_typeahead = function (query) {
return false;
}
current_token = q.substring(q.lastIndexOf('#') + 1);
if (current_token.length < 1) {
if (current_token.length === 1) {
return false;
}
current_token = current_token.substring(1);
// Don't autocomplete if there is a space following a '#'
if (current_token[0] === " ") {
return false;
}
this.completing = 'stream';
this.token = current_token.substring(current_token.indexOf("#")+1);
this.token = current_token;
return stream_data.subscribed_subs();
}
return false;