typing_data: Rename get_all_typists to get_all_direct_message_typists.

We use this function to show who's typing in the
direct messages narrow.

Renamed it because, with the addition of stream typists to
`typist_dct` in the next commit, this might be confusing.

This commit addresses the discussed issue by renaming
'get_all_typists()' to 'get_all_direct_message_typists'.
This commit is contained in:
Dinesh 2021-03-23 22:43:08 +05:30 committed by Tim Abbott
parent 91f03e0d38
commit c453a784e2
4 changed files with 11 additions and 11 deletions

View File

@ -133,7 +133,7 @@ like the following:
- `add_typist` - `add_typist`
- `remove_typist` - `remove_typist`
- `get_group_typists` - `get_group_typists`
- `get_all_typists` - `get_all_direct_message_typists`
One subtle thing that the client has to do here is to maintain One subtle thing that the client has to do here is to maintain
timers for typing notifications. The value of timers for typing notifications. The value of

View File

@ -45,7 +45,7 @@ export function get_group_typists(group: number[]): number[] {
return muted_users.filter_muted_user_ids(user_ids); return muted_users.filter_muted_user_ids(user_ids);
} }
export function get_all_typists(): number[] { export function get_all_direct_message_typists(): number[] {
let typists = [...typist_dct.values()].flat(); let typists = [...typist_dct.values()].flat();
typists = util.sorted_ids(typists); typists = util.sorted_ids(typists);
return muted_users.filter_muted_user_ids(typists); return muted_users.filter_muted_user_ids(typists);

View File

@ -47,8 +47,8 @@ function get_users_typing_for_narrow() {
const group = [...narrow_user_ids, page_params.user_id]; const group = [...narrow_user_ids, page_params.user_id];
return typing_data.get_group_typists(group); return typing_data.get_group_typists(group);
} }
// Get all users typing (in all private conversations with current user) // Get all users typing (in all direct message conversations with current user)
return typing_data.get_all_typists(); return typing_data.get_all_direct_message_typists();
} }
export function render_notifications_for_narrow() { export function render_notifications_for_narrow() {

View File

@ -34,8 +34,8 @@ test("basics", () => {
typing_data.add_typist([7, 15], 7); typing_data.add_typist([7, 15], 7);
typing_data.add_typist([7, 15], 15); typing_data.add_typist([7, 15], 15);
// test get_all_typists // test get_all_direct_message_typists
assert.deepEqual(typing_data.get_all_typists(), [7, 10, 15]); assert.deepEqual(typing_data.get_all_direct_message_typists(), [7, 10, 15]);
// test basic removal // test basic removal
assert.ok(typing_data.remove_typist([15, 7], 7)); assert.ok(typing_data.remove_typist([15, 7], 7));
@ -44,16 +44,16 @@ test("basics", () => {
// test removing an id that is not there // test removing an id that is not there
assert.ok(!typing_data.remove_typist([15, 7], 7)); assert.ok(!typing_data.remove_typist([15, 7], 7));
assert.deepEqual(typing_data.get_group_typists([7, 15]), [15]); assert.deepEqual(typing_data.get_group_typists([7, 15]), [15]);
assert.deepEqual(typing_data.get_all_typists(), [10, 15]); assert.deepEqual(typing_data.get_all_direct_message_typists(), [10, 15]);
// remove user from one group, but "15" will still be among // remove user from one group, but "15" will still be among
// "all typists" // "all typists"
assert.ok(typing_data.remove_typist([15, 7], 15)); assert.ok(typing_data.remove_typist([15, 7], 15));
assert.deepEqual(typing_data.get_all_typists(), [10, 15]); assert.deepEqual(typing_data.get_all_direct_message_typists(), [10, 15]);
// now remove from the other group // now remove from the other group
assert.ok(typing_data.remove_typist([5, 15, 10], 15)); assert.ok(typing_data.remove_typist([5, 15, 10], 15));
assert.deepEqual(typing_data.get_all_typists(), [10]); assert.deepEqual(typing_data.get_all_direct_message_typists(), [10]);
// test duplicate ids in a groups // test duplicate ids in a groups
typing_data.add_typist([20, 40, 20], 20); typing_data.add_typist([20, 40, 20], 20);
@ -66,12 +66,12 @@ test("muted_typists_excluded", () => {
// Nobody is muted. // Nobody is muted.
assert.deepEqual(typing_data.get_group_typists([5, 10, 15]), [5, 10]); assert.deepEqual(typing_data.get_group_typists([5, 10, 15]), [5, 10]);
assert.deepEqual(typing_data.get_all_typists(), [5, 10]); assert.deepEqual(typing_data.get_all_direct_message_typists(), [5, 10]);
// Mute a user, and test that the get_* functions exclude that user. // Mute a user, and test that the get_* functions exclude that user.
muted_users.add_muted_user(10); muted_users.add_muted_user(10);
assert.deepEqual(typing_data.get_group_typists([5, 10, 15]), [5]); assert.deepEqual(typing_data.get_group_typists([5, 10, 15]), [5]);
assert.deepEqual(typing_data.get_all_typists(), [5]); assert.deepEqual(typing_data.get_all_direct_message_typists(), [5]);
}); });
test("timers", () => { test("timers", () => {