mirror of https://github.com/zulip/zulip.git
Scope subject autocomplete to the stream
(imported from commit 6e9972c93d5f56f29db37b522e20768b8fb641df)
This commit is contained in:
parent
01f4aabe63
commit
35342481dc
|
@ -38,7 +38,7 @@ var globals =
|
|||
|
||||
// zephyr.js
|
||||
+ ' message_array message_dict'
|
||||
+ ' status_classes clear_table add_to_table subject_list'
|
||||
+ ' status_classes clear_table add_to_table subject_dict'
|
||||
+ ' keep_pointer_in_view move_pointer_at_page_top_and_bottom'
|
||||
+ ' respond_to_message'
|
||||
+ ' select_message select_message_by_id'
|
||||
|
|
|
@ -112,7 +112,6 @@ var autocomplete_needs_update = false;
|
|||
|
||||
function update_autocomplete() {
|
||||
stream_list.sort();
|
||||
subject_list.sort();
|
||||
people_list.sort();
|
||||
|
||||
var huddle_typeahead_list = $.map(people_list, function (person) {
|
||||
|
@ -125,7 +124,13 @@ function update_autocomplete() {
|
|||
items: 3
|
||||
});
|
||||
$( "#subject" ).typeahead({
|
||||
source: subject_list,
|
||||
source: function (query, process) {
|
||||
var stream_name = $("#stream").val();
|
||||
if (subject_dict.hasOwnProperty(stream_name)) {
|
||||
return subject_dict[stream_name];
|
||||
}
|
||||
return [];
|
||||
},
|
||||
items: 2
|
||||
});
|
||||
$( "#huddle_recipient" ).typeahead({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var message_array = [];
|
||||
var message_dict = {};
|
||||
var subject_list = [];
|
||||
var subject_dict = {};
|
||||
|
||||
$(function () {
|
||||
var i;
|
||||
|
@ -368,9 +368,14 @@ function add_message_metadata(dummy, message) {
|
|||
switch (message.type) {
|
||||
case 'stream':
|
||||
message.is_stream = true;
|
||||
if ($.inArray(message.subject, subject_list) === -1) {
|
||||
subject_list.push(message.subject);
|
||||
autocomplete_needs_update = true;
|
||||
if (! subject_dict.hasOwnProperty(message.display_recipient)) {
|
||||
subject_dict[message.display_recipient] = [];
|
||||
}
|
||||
if ($.inArray(message.subject, subject_dict[message.display_recipient]) === -1) {
|
||||
subject_dict[message.display_recipient].push(message.subject);
|
||||
subject_dict[message.display_recipient].sort();
|
||||
// We don't need to update the autocomplete after this because
|
||||
// the subject box's source is a function
|
||||
}
|
||||
message.reply_to = message.sender_email;
|
||||
|
||||
|
|
Loading…
Reference in New Issue