unmute_topic: Support unmuted topics in all messages feed.

This commit refactors the logic of the 'all messages' view to
display messages from unmuted topics within muted streams.

Previously, we hid all messages from muted streams except mentions
by checking if the stream was muted. With this new change, we also
check for unmuted topics within muted streams using the
'is_topic_unmuted' function inside 'user_topics', which returns
'true' if the topic is unmuted. If there is any unmuted topic, we
show the messages from that topic in the 'all messages' narrow.

Live update was handled by the previous commit.

Fixes part of: #24243
This commit is contained in:
palashb01 2023-04-18 20:15:49 +05:30 committed by Tim Abbott
parent ae314a3ca9
commit 6d1efdc013
1 changed files with 8 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import {page_params} from "./page_params";
import * as people from "./people";
import * as stream_data from "./stream_data";
import * as unread from "./unread";
import * as user_topics from "./user_topics";
import * as util from "./util";
function zephyr_stream_name_match(message, operand) {
@ -56,6 +57,9 @@ function zephyr_topic_name_match(message, operand) {
}
function message_in_home(message) {
// The home view contains messages not sent to muted streams, with
// additional logic for unmuted topics, mentions, and
// single-stream windows.
if (
message.type === "private" ||
message.mentioned ||
@ -65,8 +69,10 @@ function message_in_home(message) {
return true;
}
// We don't display muted streams in 'All messages' view
return !stream_data.is_muted(message.stream_id);
return (
!stream_data.is_muted(message.stream_id) ||
user_topics.is_topic_unmuted(message.stream_id, message.topic)
);
}
function message_matches_search_term(message, operator, operand) {