recent: Add support for unmuted topics within muted streams.

This commit refactors the logic of message filtering for
'Recent conversations' narrow.

Previously, we used to filter the recent conversations messages
based on the state of the stream and topic. If the stream or topic
was muted, we would avoid displaying the message. However, with
the new changes, we check if the topic is unmuted before applying
the aforementioned condition. If the topic is unmuted, we add the
message to the all 'Recent conversations' narrow.

Fixes part of: #24243
This commit is contained in:
palashb01 2023-04-15 04:41:26 +05:30 committed by Tim Abbott
parent ed4de6da4a
commit acb4d7efa6
2 changed files with 4 additions and 1 deletions

View File

@ -541,9 +541,11 @@ export function filters_should_hide_topic(topic_data) {
}
if (!filters.has("include_muted") && topic_data.type === "stream") {
// We want to show the unmuted topics within muted streams in the recent topics.
const topic_unmuted = Boolean(user_topics.is_topic_unmuted(msg.stream_id, msg.topic));
const topic_muted = Boolean(user_topics.is_topic_muted(msg.stream_id, msg.topic));
const stream_muted = stream_data.is_muted(msg.stream_id);
if (topic_muted || stream_muted) {
if (topic_muted || (stream_muted && !topic_unmuted)) {
return true;
}
}

View File

@ -107,6 +107,7 @@ mock_esm("../src/user_topics", {
}
return false;
},
is_topic_unmuted: () => false,
});
const narrow = mock_esm("../src/narrow", {
update_narrow_title: noop,