mirror of https://github.com/zulip/zulip.git
Handle case where @-replies are not at beginning of msg
(imported from commit 2ed80845f49f48de71a5ea1db382dc4d9369f393)
This commit is contained in:
parent
64a08a5496
commit
639ec9380a
|
@ -169,7 +169,7 @@ exports.initialize = function () {
|
||||||
// Case-insensitive.
|
// Case-insensitive.
|
||||||
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
|
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
|
||||||
},
|
},
|
||||||
sorter: typeahead_helper.sort_recipients,
|
sorter: typeahead_helper.sort_recipientbox_typeahead,
|
||||||
updater: function (item) {
|
updater: function (item) {
|
||||||
var previous_recipients = exports.get_cleaned_pm_recipients(this.query);
|
var previous_recipients = exports.get_cleaned_pm_recipients(this.query);
|
||||||
previous_recipients.pop();
|
previous_recipients.pop();
|
||||||
|
@ -200,7 +200,7 @@ exports.initialize = function () {
|
||||||
// Case-insensitive.
|
// Case-insensitive.
|
||||||
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
|
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
|
||||||
},
|
},
|
||||||
sorter: typeahead_helper.sort_recipients,
|
sorter: typeahead_helper.sort_textbox_typeahead,
|
||||||
updater: function (item) {
|
updater: function (item) {
|
||||||
return this.query.replace(/@\S+$/, "") + "@" + typeahead_helper.private_message_mapped[item].email.split("@")[0];
|
return this.query.replace(/@\S+$/, "") + "@" + typeahead_helper.private_message_mapped[item].email.split("@")[0];
|
||||||
},
|
},
|
||||||
|
|
|
@ -140,18 +140,29 @@ exports.sort_subjects = function (items) {
|
||||||
return exports.sorter(this.query, items, identity);
|
return exports.sorter(this.query, items, identity);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.sort_recipients = function (matches) {
|
exports.sort_recipients = function (matches, query) {
|
||||||
var cleaned = composebox_typeahead.get_cleaned_pm_recipients(this.query);
|
|
||||||
var query = cleaned[cleaned.length - 1];
|
|
||||||
if (query[0] === '@')
|
|
||||||
query = query.substring(1);
|
|
||||||
|
|
||||||
var name_results = prefix_sort(query, matches, identity);
|
var name_results = prefix_sort(query, matches, identity);
|
||||||
var email_results = prefix_sort(query, name_results.rest, email_from_identity);
|
var email_results = prefix_sort(query, name_results.rest, email_from_identity);
|
||||||
var sorted_by_pms = exports.sort_by_pms(email_results.rest);
|
var sorted_by_pms = exports.sort_by_pms(email_results.rest);
|
||||||
return name_results.matches.concat(email_results.matches.concat(sorted_by_pms));
|
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;
|
return exports;
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in New Issue