Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typing notifications: Exclude muted typists.

Abhijeet Prasad Bodas04c355c248dd
diff --git a/frontend_tests/node_tests/typing_data.js b/frontend_tests/node_tests/typing_data.js
index d923d94c55d..ead644c1e18 100644
--- a/frontend_tests/node_tests/typing_data.js
+++ b/frontend_tests/node_tests/typing_data.js
@@ -5,11 +5,13 @@ const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
+const muting = zrequire("muting");
const typing_data = zrequire("typing_data");
function test(label, f) {
run_test(label, (override) => {
typing_data.clear_for_testing();
+ muting.set_muted_users([]);
f(override);
});
}
@@ -59,6 +61,20 @@ test("basics", () => {
assert.deepEqual(typing_data.get_group_typists([20, 40]), [20]);
});
+test("muted_typists_excluded", () => {
+ typing_data.add_typist([5, 10, 15], 5);
+ typing_data.add_typist([5, 10, 15], 10);
+
+ // Nobody is muted.
+ assert.deepEqual(typing_data.get_group_typists([5, 10, 15]), [5, 10]);
+ assert.deepEqual(typing_data.get_all_typists(), [5, 10]);
+
+ // Mute a user, and test that the get_* functions exclude that user.
+ muting.add_muted_user(10);
+ assert.deepEqual(typing_data.get_group_typists([5, 10, 15]), [5]);
+ assert.deepEqual(typing_data.get_all_typists(), [5]);
+});
+
test("timers", () => {
const events = {};
diff --git a/static/js/typing_data.js b/static/js/typing_data.js
index 1c39d705881..d909a299dd5 100644
--- a/static/js/typing_data.js
+++ b/static/js/typing_data.js
@@ -1,5 +1,6 @@
import _ from "lodash";
+import * as muting from "./muting";
import * as util from "./util";
// See docs/subsystems/typing-indicators.md for details on typing indicators.
@@ -48,14 +49,15 @@ export function remove_typist(group, typist) {
export function get_group_typists(group) {
const key = get_key(group);
- return typist_dct.get(key) || [];
+ const user_ids = typist_dct.get(key) || [];
+ return muting.filter_muted_user_ids(user_ids);
}
export function get_all_typists() {
let typists = [].concat(...Array.from(typist_dct.values()));
typists = util.sorted_ids(typists);
typists = _.sortedUniq(typists);
- return typists;
+ return muting.filter_muted_user_ids(typists);
}
// The next functions aren't pure data, but it is easy