Handle case where @-replies are not at beginning of msg

(imported from commit 2ed80845f49f48de71a5ea1db382dc4d9369f393)
This commit is contained in:
Leo Franchi 2013-01-25 16:04:17 -05:00
parent 64a08a5496
commit 639ec9380a
2 changed files with 19 additions and 8 deletions

View File

@ -169,7 +169,7 @@ exports.initialize = function () {
// Case-insensitive.
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
},
sorter: typeahead_helper.sort_recipients,
sorter: typeahead_helper.sort_recipientbox_typeahead,
updater: function (item) {
var previous_recipients = exports.get_cleaned_pm_recipients(this.query);
previous_recipients.pop();
@ -200,7 +200,7 @@ exports.initialize = function () {
// Case-insensitive.
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
},
sorter: typeahead_helper.sort_recipients,
sorter: typeahead_helper.sort_textbox_typeahead,
updater: function (item) {
return this.query.replace(/@\S+$/, "") + "@" + typeahead_helper.private_message_mapped[item].email.split("@")[0];
},

View File

@ -140,18 +140,29 @@ exports.sort_subjects = function (items) {
return exports.sorter(this.query, items, identity);
};
exports.sort_recipients = function (matches) {
var cleaned = composebox_typeahead.get_cleaned_pm_recipients(this.query);
var query = cleaned[cleaned.length - 1];
if (query[0] === '@')
query = query.substring(1);
exports.sort_recipients = function (matches, query) {
var name_results = prefix_sort(query, matches, identity);
var email_results = prefix_sort(query, name_results.rest, email_from_identity);
var sorted_by_pms = exports.sort_by_pms(email_results.rest);
return name_results.matches.concat(email_results.matches.concat(sorted_by_pms));
};
exports.sort_textbox_typeahead = function(matches) {
// input may be free text ending in @ for autocomplete
var query = this.query;
if (query.indexOf('@') > -1) {
var parts = this.query.split('@');
query = parts[parts.length - 1];
}
return exports.sort_recipients(matches, query);
};
exports.sort_recipientbox_typeahead = function(matches) {
// input_text may be one or more pm recipients
var cleaned = composebox_typeahead.get_cleaned_pm_recipients(this.query);
var query = cleaned[cleaned.length - 1];
return exports.sort_recipients(matches, query);};
return exports;
}());