mirror of https://github.com/zulip/zulip.git
Maintain a list of people in the realm.
people_list and people_dict include the feedback bot and anyone you've cross-realm PM'd with. Useful for autocomplete, but not for admin and stream settings views. Fixes the UI part of Trac #1772. (imported from commit cdefd4e86980447aad5190e7fc8ae3666d66e3c3)
This commit is contained in:
parent
45b14a0c96
commit
810dd89621
|
@ -9,7 +9,7 @@ function populate_users () {
|
|||
return a.full_name.toLowerCase().localeCompare(b.full_name.toLowerCase());
|
||||
});
|
||||
|
||||
$.each(page_params.people_list, function (index, person) {
|
||||
realm_people_dict.each(function (person, key) {
|
||||
if (!person.is_bot) {
|
||||
tb.append(templates.render("admin_user_list", {person: person}));
|
||||
}
|
||||
|
|
|
@ -599,12 +599,8 @@ function update_announce_stream_state() {
|
|||
|
||||
function show_new_stream_modal() {
|
||||
var people_minus_you_and_internal_users = [];
|
||||
_.each(page_params.people_list, function (person) {
|
||||
if (person.email !== page_params.email &&
|
||||
(page_params.domain === "zulip.com" ||
|
||||
person.email.split('@')[1] !== "zulip.com"
|
||||
)
|
||||
) {
|
||||
realm_people_dict.each(function (person) {
|
||||
if (person.email !== page_params.email) {
|
||||
people_minus_you_and_internal_users.push({"email": person.email,
|
||||
"full_name": person.full_name});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,13 @@ var home_msg_list = new MessageList('zhome',
|
|||
);
|
||||
var narrowed_msg_list;
|
||||
var current_msg_list = home_msg_list;
|
||||
|
||||
// The following two Dicts point to the same objects
|
||||
// All people we've seen
|
||||
var people_dict = new Dict();
|
||||
// People in this realm
|
||||
var realm_people_dict = new Dict();
|
||||
|
||||
var recent_subjects = new Dict({fold_case: true});
|
||||
|
||||
var queued_mark_as_read = [];
|
||||
|
@ -39,12 +45,17 @@ var events_stored_during_tutorial = [];
|
|||
|
||||
var waiting_on_browser_scroll = true;
|
||||
|
||||
function add_person(person) {
|
||||
function add_person(person, in_realm) {
|
||||
page_params.people_list.push(person);
|
||||
people_dict.set(person.email, person);
|
||||
person.pm_recipient_count = 0;
|
||||
}
|
||||
|
||||
function add_person_in_realm(person) {
|
||||
realm_people_dict.set(person.email, person);
|
||||
add_person(person);
|
||||
}
|
||||
|
||||
function remove_person(person) {
|
||||
var i;
|
||||
for (i = 0; i < page_params.people_list.length; i++) {
|
||||
|
@ -54,6 +65,7 @@ function remove_person(person) {
|
|||
}
|
||||
}
|
||||
people_dict.del(person.email);
|
||||
realm_people_dict.del(person.email);
|
||||
}
|
||||
|
||||
function update_person(person) {
|
||||
|
@ -68,6 +80,8 @@ function update_person(person) {
|
|||
return;
|
||||
}
|
||||
people_dict.get(person.email).full_name = person.full_name;
|
||||
// This should be the same object, but...
|
||||
realm_people_dict.get(person.email).full_name = person.full_name;
|
||||
for (i = 0; i < page_params.people_list.length; i++) {
|
||||
if (page_params.people_list[i].email === person.email) {
|
||||
page_params.people_list[i].full_name = person.full_name;
|
||||
|
@ -821,7 +835,7 @@ function get_updates_success(data) {
|
|||
break;
|
||||
case 'realm_user':
|
||||
if (event.op === 'add') {
|
||||
add_person(event.person);
|
||||
add_person_in_realm(event.person);
|
||||
} else if (event.op === 'remove') {
|
||||
remove_person(event.person);
|
||||
} else if (event.op === 'update') {
|
||||
|
@ -1228,6 +1242,7 @@ function consider_bankruptcy() {
|
|||
|
||||
_.each(page_params.people_list, function (person) {
|
||||
people_dict.set(person.email, person);
|
||||
realm_people_dict.set(person.email, person);
|
||||
person.pm_recipient_count = 0;
|
||||
});
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ var globals =
|
|||
// zulip.js
|
||||
+ ' all_msg_list home_msg_list narrowed_msg_list current_msg_list get_updates_params'
|
||||
+ ' add_messages'
|
||||
+ ' people_dict'
|
||||
+ ' people_dict realm_people_dict'
|
||||
+ ' keep_pointer_in_view'
|
||||
+ ' respond_to_message recenter_view last_viewport_movement_direction'
|
||||
+ ' scroll_to_selected get_private_message_recipient'
|
||||
|
|
Loading…
Reference in New Issue