message list: Don't exclude 1:1 PMs with muted users in pm-with narrows.

Previously, we used to hide 1:1 PMs with muted users everywhere
in the UI. This commit makes it so that such messages will now be
visible in `pm-with/<muted_user>` narrows, meaning these will not
be excluded from message lists, but will still be hidden under
the "This message was hidden." dialog implemented earlier.
This commit is contained in:
Abhijeet Prasad Bodas
2021-05-05 16:38:49 +05:30
committed by Tim Abbott
parent a59f545136
commit eadbce4b0c
2 changed files with 22 additions and 0 deletions

View File

@@ -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: "alice@example.com"}]),
});
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, [