mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 05:58:25 +00:00
typeahead: Show only active users in mention typeaheads.
'get_active_message_people` function is added which returns active users who have sent the messages that are currently showing up in the feed. typeahead fetches the users from 'get_active_message_people` instead of `get_message_people` and thus shows only active users in the mention typeahead and excludes deactivated users. Fixes #14310
This commit is contained in:
@@ -1526,4 +1526,14 @@ run_test('message people', () => {
|
|||||||
|
|
||||||
results = ct.get_person_suggestions('Ha', opts);
|
results = ct.get_person_suggestions('Ha', opts);
|
||||||
assert.deepEqual(results, [harry, hamletcharacters]);
|
assert.deepEqual(results, [harry, hamletcharacters]);
|
||||||
|
|
||||||
|
message_store.user_ids = () => [hamlet.user_id, harry.user_id, hal.user_id];
|
||||||
|
|
||||||
|
results = ct.get_person_suggestions('Ha', opts);
|
||||||
|
assert.deepEqual(results, [harry, hamletcharacters]);
|
||||||
|
|
||||||
|
people.deactivate(harry);
|
||||||
|
results = ct.get_person_suggestions('Ha', opts);
|
||||||
|
// harry is excluded since it has been deactivated.
|
||||||
|
assert.deepEqual(results, [hamletcharacters, hal]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1080,3 +1080,38 @@ run_test('get_visible_email', function () {
|
|||||||
email = people.get_visible_email(maria);
|
email = people.get_visible_email(maria);
|
||||||
assert.equal(email, maria.email);
|
assert.equal(email, maria.email);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
run_test('get_active_message_people', function () {
|
||||||
|
const steven = {
|
||||||
|
email: 'steven@example.com',
|
||||||
|
user_id: 1,
|
||||||
|
full_name: 'Steven',
|
||||||
|
};
|
||||||
|
|
||||||
|
const maria = {
|
||||||
|
email: 'maria@example.com',
|
||||||
|
user_id: 2,
|
||||||
|
full_name: 'Maria',
|
||||||
|
};
|
||||||
|
|
||||||
|
const alice = {
|
||||||
|
email: 'alice@example.com',
|
||||||
|
user_id: 3,
|
||||||
|
full_name: 'Alice',
|
||||||
|
};
|
||||||
|
|
||||||
|
message_store.user_ids = () => {
|
||||||
|
return [1, 2, 3];
|
||||||
|
};
|
||||||
|
|
||||||
|
people.add(steven);
|
||||||
|
people.add(maria);
|
||||||
|
people.add(alice);
|
||||||
|
|
||||||
|
let active_message_people = people.get_active_message_people();
|
||||||
|
assert.deepEqual(active_message_people, [steven, maria, alice]);
|
||||||
|
|
||||||
|
people.deactivate(alice);
|
||||||
|
active_message_people = people.get_active_message_people();
|
||||||
|
assert.deepEqual(active_message_people, [steven, maria]);
|
||||||
|
});
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ exports.get_person_suggestions = function (query, opts) {
|
|||||||
const cutoff_length = exports.max_num_items;
|
const cutoff_length = exports.max_num_items;
|
||||||
|
|
||||||
const filtered_message_persons = filter_persons(
|
const filtered_message_persons = filter_persons(
|
||||||
people.get_message_people()
|
people.get_active_message_people()
|
||||||
);
|
);
|
||||||
|
|
||||||
let filtered_persons;
|
let filtered_persons;
|
||||||
|
|||||||
@@ -797,6 +797,14 @@ exports.get_message_people = function () {
|
|||||||
return message_people;
|
return message_people;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.get_active_message_people = function () {
|
||||||
|
const message_people = exports.get_message_people();
|
||||||
|
const active_message_people = message_people.filter(function (item) {
|
||||||
|
return active_user_dict.has(item.user_id);
|
||||||
|
});
|
||||||
|
return active_message_people;
|
||||||
|
};
|
||||||
|
|
||||||
exports.get_people_for_search_bar = function (query) {
|
exports.get_people_for_search_bar = function (query) {
|
||||||
const pred = exports.build_person_matcher(query);
|
const pred = exports.build_person_matcher(query);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user