util: Move is_pm_recipient to compose_fade_helper.

"is_pm_recipient" is not supposed to be called with an arbitrary
recipient object which might have "to_user_ids" being undefined.
Since this helper is only used with focused_recipient in
compose_fade_helper, we move it there.

Note that the helper is no longer separately tested. It is now covered
by the test case of "compose_fade_helper.would_receive_message".

(See
5e74a8d0cc/static/js/compose.js (L156-L162))

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-12-05 16:56:24 -05:00
committed by Tim Abbott
parent 55793cb4d5
commit b757c1a9b6
3 changed files with 6 additions and 12 deletions

View File

@@ -32,13 +32,6 @@ run_test("extract_pm_recipients", () => {
assert.equal(util.extract_pm_recipients("bob@foo.com, ").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}];