mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
typeahead_helper: Rename render_pm_object and cleanup usage.
(imported from commit 28bca00802e189daed22dcabba1241ef2625536e)
This commit is contained in:
parent
49af19aa71
commit
096df2d3da
@ -13,23 +13,31 @@ var search_active = false;
|
||||
var labels = [];
|
||||
var mapped = {};
|
||||
|
||||
function get_query(obj) {
|
||||
return obj.query;
|
||||
}
|
||||
|
||||
function get_person(obj) {
|
||||
return typeahead_helper.render_person(obj.query);
|
||||
}
|
||||
|
||||
function render_object_in_parts(obj) {
|
||||
// N.B. action is *not* escaped by the caller
|
||||
switch (obj.action) {
|
||||
case 'search':
|
||||
return {prefix: 'Find', query: obj.query, suffix: 'in page'};
|
||||
return {prefix: 'Find', query: get_query(obj), suffix: 'in page'};
|
||||
|
||||
case 'stream':
|
||||
return {prefix: 'Narrow to stream', query: obj.query, suffix: ''};
|
||||
return {prefix: 'Narrow to stream', query: get_query(obj), suffix: ''};
|
||||
|
||||
case 'private_message':
|
||||
return {prefix: 'Narrow to private messages with',
|
||||
query: typeahead_helper.render_pm_object(obj.query),
|
||||
query: get_person(obj),
|
||||
suffix: ''};
|
||||
|
||||
case 'sender':
|
||||
return {prefix: 'Narrow to messages sent by',
|
||||
query: typeahead_helper.render_pm_object(obj.query),
|
||||
query: get_person(obj),
|
||||
suffix: ''};
|
||||
|
||||
case 'operators':
|
||||
@ -114,14 +122,6 @@ function narrow_or_search_for_term(item) {
|
||||
return item;
|
||||
}
|
||||
|
||||
function get_query(obj) {
|
||||
return obj.query;
|
||||
}
|
||||
|
||||
function get_person(obj) {
|
||||
return typeahead_helper.render_pm_object(obj.query);
|
||||
}
|
||||
|
||||
function searchbox_sorter(items) {
|
||||
var objects_by_action = {};
|
||||
var result = [];
|
||||
|
||||
@ -46,12 +46,12 @@ exports.highlight_with_escaping = function (query, item) {
|
||||
exports.private_message_typeahead_list = [];
|
||||
exports.private_message_mapped = {};
|
||||
|
||||
exports.render_pm_object = function (person) {
|
||||
exports.render_person = function (person) {
|
||||
return person.full_name + " <" + person.email + ">";
|
||||
};
|
||||
|
||||
function add_to_known_recipients(recipient_data, count_towards_autocomplete_preference) {
|
||||
var name_string = exports.render_pm_object(recipient_data);
|
||||
var name_string = exports.render_person(recipient_data);
|
||||
if (exports.private_message_mapped[name_string] === undefined) {
|
||||
exports.private_message_mapped[name_string] = recipient_data;
|
||||
exports.private_message_mapped[name_string].count = 0;
|
||||
@ -63,7 +63,7 @@ function add_to_known_recipients(recipient_data, count_towards_autocomplete_pref
|
||||
}
|
||||
|
||||
exports.known_to_typeahead = function (recipient_data) {
|
||||
return exports.private_message_mapped[exports.render_pm_object(recipient_data)] !== undefined;
|
||||
return exports.private_message_mapped[exports.render_person(recipient_data)] !== undefined;
|
||||
};
|
||||
|
||||
exports.update_all_recipients = function (recipients) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user