mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
Move update_autocomplete into typeahead_helper.
(imported from commit e15446e09869da482dbe554b824ea8bb6f060cf1)
This commit is contained in:
@@ -13,16 +13,6 @@ var composebox_typeahead = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
var autocomplete_needs_update = false;
|
||||
|
||||
exports.autocomplete_needs_update = function (needs_update) {
|
||||
if (needs_update === undefined) {
|
||||
return autocomplete_needs_update;
|
||||
} else {
|
||||
autocomplete_needs_update = needs_update;
|
||||
}
|
||||
};
|
||||
|
||||
var private_message_typeahead_list = [];
|
||||
var private_message_mapped = {};
|
||||
|
||||
@@ -30,14 +20,7 @@ function render_pm_object(person) {
|
||||
return person.full_name + " <" + person.email + ">";
|
||||
}
|
||||
|
||||
exports.update_autocomplete = function () {
|
||||
stream_list.sort();
|
||||
people_list.sort(function (x, y) {
|
||||
if (x.email === y.email) return 0;
|
||||
if (x.email < y.email) return -1;
|
||||
return 1;
|
||||
});
|
||||
|
||||
exports.update_typeahead = function() {
|
||||
private_message_mapped = {};
|
||||
private_message_typeahead_list = [];
|
||||
$.each(people_list, function (i, obj) {
|
||||
@@ -45,8 +28,6 @@ exports.update_autocomplete = function () {
|
||||
private_message_mapped[label] = obj;
|
||||
private_message_typeahead_list.push(label);
|
||||
});
|
||||
|
||||
autocomplete_needs_update = false;
|
||||
};
|
||||
|
||||
function get_pm_recipients(query_string) {
|
||||
@@ -200,7 +181,7 @@ exports.initialize = function () {
|
||||
$(this).val(recipients.join(", "));
|
||||
});
|
||||
|
||||
composebox_typeahead.update_autocomplete();
|
||||
typeahead_helper.update_autocomplete();
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
@@ -142,7 +142,7 @@ exports.unsubscribe = function (stream) {
|
||||
ajaxSubscribe(name);
|
||||
});
|
||||
remove_from_stream_list(name);
|
||||
composebox_typeahead.update_autocomplete();
|
||||
typeahead_helper.update_autocomplete();
|
||||
$("#streams").focus();
|
||||
},
|
||||
error: function (xhr) {
|
||||
|
||||
@@ -2,6 +2,28 @@ var typeahead_helper = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
var autocomplete_needs_update = false;
|
||||
exports.autocomplete_needs_update = function (needs_update) {
|
||||
if (needs_update === undefined) {
|
||||
return autocomplete_needs_update;
|
||||
} else {
|
||||
autocomplete_needs_update = needs_update;
|
||||
}
|
||||
};
|
||||
|
||||
exports.update_autocomplete = function () {
|
||||
stream_list.sort();
|
||||
people_list.sort(function (x, y) {
|
||||
if (x.email === y.email) return 0;
|
||||
if (x.email < y.email) return -1;
|
||||
return 1;
|
||||
});
|
||||
|
||||
composebox_typeahead.update_typeahead();
|
||||
autocomplete_needs_update = false;
|
||||
};
|
||||
|
||||
|
||||
// Loosely based on Bootstrap's default highlighter, but with escaping added.
|
||||
exports.highlight_with_escaping = function (query, item) {
|
||||
// query: The text currently in the searchbox
|
||||
|
||||
@@ -434,7 +434,7 @@ function add_message_metadata(dummy, message) {
|
||||
if (! Object.prototype.hasOwnProperty.call(people_set, person.email)) {
|
||||
people_set[person.email] = true;
|
||||
people_list.push(person);
|
||||
composebox_typeahead.autocomplete_needs_update(true);
|
||||
typeahead_helper.autocomplete_needs_update(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -496,8 +496,8 @@ function add_messages(messages, where, add_to_home) {
|
||||
{then_scroll: true, update_server: false});
|
||||
}
|
||||
|
||||
if (composebox_typeahead.autocomplete_needs_update()) {
|
||||
composebox_typeahead.update_autocomplete();
|
||||
if (typeahead_helper.autocomplete_needs_update()) {
|
||||
typeahead_helper.update_autocomplete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user