Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message list: Don't exclude 1:1 PMs with muted users in pm-with narrows.
Abhijeet Prasad Bodaseadbce4b0c33
diff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.jsindex 07985861f9d..cd4da59cda4 100644--- a/frontend_tests/node_tests/message_list_data.js+++ b/frontend_tests/node_tests/message_list_data.js@@ -13,6 +13,7 @@ set_global("setTimeout", (f, delay) => {const muting = zrequire("muting");const {MessageListData} = zrequire("../js/message_list_data");+const {Filter} = zrequire("filter");function make_msg(msg_id) {return {@@ -108,6 +109,7 @@ run_test("basics", () => {run_test("muting", () => {let mld = new MessageListData({excludes_muted_topics: false,+ filter: new Filter([{operator: "pm-with", operand: "[email protected]"}]),});const msgs = [@@ -140,8 +142,23 @@ run_test("muting", () => {},);+ // If we are in a 1:1 PM narrow, `messages_filtered_for_user_mutes` should skip+ // filtering messages.+ with_field(+ muting,+ "is_user_muted",+ () => {+ throw new Error("Messages should not be filtered for user mutes in 1:1 PM narrows.");+ },+ () => {+ const res = mld.messages_filtered_for_user_mutes(msgs);+ assert.deepEqual(res, msgs);+ },+ );+// Test actual behaviour of `messages_filtered_for_*` methods.mld.excludes_muted_topics = true;+ mld.filter = new Filter([{operator: "stream", operand: "general"}]);muting.add_muted_topic(1, "muted");const res = mld.messages_filtered_for_topic_mutes(msgs);assert.deepEqual(res, [diff --git a/static/js/message_list_data.js b/static/js/message_list_data.jsindex 38717daa638..11dce6bdfa1 100644--- a/static/js/message_list_data.js+++ b/static/js/message_list_data.js@@ -178,6 +178,11 @@ export class MessageListData {}messages_filtered_for_user_mutes(messages) {+ if (this.filter.is_non_huddle_pm()) {+ // We are in a 1:1 PM narrow, so do not do any filtering.+ return [...messages];+ }+return messages.filter((message) => {if (message.type !== "private") {return true;