mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
buddy list: Relax count limit when doing searches.
A recent change filtered out offline users from the buddy list whenever the list size would otherwise exceed 600. This commit reverts half that change--we can now show 600+ users again, but only when searching.
This commit is contained in:
@@ -14,7 +14,7 @@ set_global('page_params', {});
|
||||
_.each(_.range(1000, 2000), (i) => {
|
||||
const person = {
|
||||
user_id: i,
|
||||
full_name: `Person ${i}`,
|
||||
full_name: `Human ${i}`,
|
||||
email: `person${i}@example.com`,
|
||||
};
|
||||
people.add_in_realm(person);
|
||||
@@ -42,9 +42,35 @@ set_global('page_params', {});
|
||||
}());
|
||||
|
||||
(function test_user_ids() {
|
||||
const user_ids = buddy_data.get_filtered_and_sorted_user_ids();
|
||||
var user_ids;
|
||||
|
||||
// Even though we have 900 users, we only get the 400 active
|
||||
// Even though we have 1000 users, we only get the 400 active
|
||||
// users. This is a consequence of buddy_data.maybe_shrink_list.
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids();
|
||||
assert.equal(user_ids.length, 400);
|
||||
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('');
|
||||
assert.equal(user_ids.length, 400);
|
||||
|
||||
// We don't match on "s", because it's not at the start of a
|
||||
// word in the name/email.
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('s');
|
||||
assert.equal(user_ids.length, 0);
|
||||
|
||||
// We match on "h" for the first name, and the result limit
|
||||
// is relaxed for searches.
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('h');
|
||||
assert.equal(user_ids.length, 1000);
|
||||
|
||||
// We match on "p" for the email.
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('p');
|
||||
assert.equal(user_ids.length, 1000);
|
||||
|
||||
|
||||
// Make our shrink limit higher, and go back to an empty search.
|
||||
// We won't get all 1000 users, just the present ones.
|
||||
buddy_data.max_size_before_shrinking = 50000;
|
||||
|
||||
user_ids = buddy_data.get_filtered_and_sorted_user_ids('');
|
||||
assert.equal(user_ids.length, 700);
|
||||
}());
|
||||
|
||||
@@ -11,7 +11,7 @@ var exports = {};
|
||||
|
||||
*/
|
||||
|
||||
var max_size_before_shrinking = 600;
|
||||
exports.max_size_before_shrinking = 600;
|
||||
|
||||
var presence_descriptions = {
|
||||
active: 'is active',
|
||||
@@ -108,8 +108,18 @@ function user_is_recently_active(user_id) {
|
||||
return level(presence.get_status(user_id)) <= 2;
|
||||
}
|
||||
|
||||
function maybe_shrink_list(user_ids) {
|
||||
if (user_ids.length <= max_size_before_shrinking) {
|
||||
function maybe_shrink_list(user_ids, filter_text) {
|
||||
if (user_ids.length <= exports.max_size_before_shrinking) {
|
||||
return user_ids;
|
||||
}
|
||||
|
||||
if (filter_text) {
|
||||
// If the user types something, we want to show all
|
||||
// users matching the text, even if they have not been
|
||||
// online recently.
|
||||
// For super common letters like "s", we may
|
||||
// eventually want to filter down to only users that
|
||||
// are in presence.get_user_ids().
|
||||
return user_ids;
|
||||
}
|
||||
|
||||
@@ -132,7 +142,7 @@ exports.get_filtered_and_sorted_user_ids = function (filter_text) {
|
||||
user_ids = presence.get_user_ids();
|
||||
}
|
||||
|
||||
user_ids = maybe_shrink_list(user_ids);
|
||||
user_ids = maybe_shrink_list(user_ids, filter_text);
|
||||
|
||||
return exports.sort_users(user_ids);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user