Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

unread: Extract unmuted context check to helper function.

santhoshkumarCodesd5f34e4445fb
diff --git a/web/src/unread.ts b/web/src/unread.ts
index 0c329f12eda..7e1c6af534a 100644
--- a/web/src/unread.ts
+++ b/web/src/unread.ts
@@ -827,6 +827,20 @@ export function process_unread_message(message: UnreadMessageData): void {
update_message_for_mention(message);
}
+function is_message_in_unmuted_context(message: UnreadMessageData | Message): boolean {
+ // A message is in unmuted context if:
+ // - the message is a direct message or
+ // - the message is in a non muted topic in an unmuted stream or
+ // - the message is in a followed or an unmuted topic in a muted stream.
+ return (
+ message.type === "private" ||
+ (!stream_data.is_muted(message.stream_id) &&
+ !user_topics.is_topic_muted(message.stream_id, message.topic)) ||
+ (stream_data.is_muted(message.stream_id) &&
+ user_topics.is_topic_unmuted_or_followed(message.stream_id, message.topic))
+ );
+}
+
export function update_message_for_mention(
message: UnreadMessageData | Message,
content_edited = false,
@@ -842,17 +856,7 @@ export function update_message_for_mention(
return false;
}
- // A message is said to have an unmuted mention if message contains a mention and
- // if the message is a direct message or
- // if the message is in a non muted topic in an unmuted stream or
- // if the message is in a followed or an unmuted topic in a muted stream.
- const is_unmuted_mention =
- message.mentioned &&
- (message.type === "private" ||
- (!stream_data.is_muted(message.stream_id) &&
- !user_topics.is_topic_muted(message.stream_id, message.topic)) ||
- (stream_data.is_muted(message.stream_id) &&
- user_topics.is_topic_unmuted_or_followed(message.stream_id, message.topic)));
+ const is_unmuted_mention = message.mentioned && is_message_in_unmuted_context(message);
if (is_unmuted_mention || message.mentioned_me_directly) {
unread_mentions_counter.add(message.id);