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.

util: Move is_pm_recipient to compose_fade_helper.

Zixuan James Lib757c1a9b634
diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js
index 56ccf7b1305..f6348024a58 100644
--- a/frontend_tests/node_tests/util.js
+++ b/frontend_tests/node_tests/util.js
@@ -32,13 +32,6 @@ run_test("extract_pm_recipients", () => {
assert.equal(util.extract_pm_recipients("[email protected], ").length, 1);
});
-run_test("is_pm_recipient", () => {
- const message = {to_user_ids: "31,32,33"};
- assert.ok(util.is_pm_recipient(31, message));
- assert.ok(util.is_pm_recipient(32, message));
- assert.ok(!util.is_pm_recipient(34, message));
-});
-
run_test("lower_bound", () => {
const arr = [{x: 10}, {x: 20}, {x: 30}, {x: 40}, {x: 50}];
diff --git a/static/js/compose_fade_helper.js b/static/js/compose_fade_helper.js
index 080f6ec5c93..c4d7e3066c0 100644
--- a/static/js/compose_fade_helper.js
+++ b/static/js/compose_fade_helper.js
@@ -16,6 +16,11 @@ export function set_focused_recipient(recipient) {
focused_recipient = recipient;
}
+function is_pm_recipient(user_id) {
+ const recipients = focused_recipient.to_user_ids.split(",");
+ return recipients.includes(user_id.toString());
+}
+
export function would_receive_message(user_id) {
if (focused_recipient.type === "stream") {
const sub = sub_store.get(focused_recipient.stream_id);
@@ -30,7 +35,7 @@ export function would_receive_message(user_id) {
}
// PM, so check if the given email is in the recipients list.
- return util.is_pm_recipient(user_id, focused_recipient);
+ return is_pm_recipient(user_id);
}
export function want_normal_display() {
diff --git a/static/js/util.js b/static/js/util.js
index fe5a722d783..aa65f1998ab 100644
--- a/static/js/util.js
+++ b/static/js/util.js
@@ -55,10 +55,6 @@ export const same_stream_and_topic = function util_same_stream_and_topic(a, b) {
return a.stream_id === b.stream_id && lower_same(a.topic, b.topic);
};
-export function is_pm_recipient(user_id, message) {
- const recipients = message.to_user_ids.split(",");
- return recipients.includes(user_id.toString());
-}
export function extract_pm_recipients(recipients) {
return recipients.split(/\s*[,;]\s*/).filter((recipient) => recipient.trim() !== "");