Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Show unread_mention in regular font if in unmuted topic.
Hardik Dharmani98162b7a3a01
diff --git a/web/src/stream_list.js b/web/src/stream_list.jsindex 6523f86a625..a4102628fe6 100644--- a/web/src/stream_list.js+++ b/web/src/stream_list.js@@ -37,18 +37,24 @@ export function update_count_in_dom($stream_li,stream_counts,stream_has_any_unread_mention_messages,+ stream_has_any_unmuted_unread_mention,) {// The subscription_block properly excludes the topic list,// and it also has sensitive margins related to whether the// count is there or not.const $subscription_block = $stream_li.find(".subscription_block");- ui_util.update_unread_count_in_dom($subscription_block, count);ui_util.update_unread_mention_info_in_dom($subscription_block,stream_has_any_unread_mention_messages,);+ if (stream_has_any_unmuted_unread_mention) {+ $subscription_block.addClass("has-unmuted-mentions");+ } else {+ $subscription_block.removeClass("has-unmuted-mentions");+ }+// Here we set the count and compute the values of two classes:// .stream-with-count is used for the layout CSS to know whether// to leave space for the unread count, and has-unmuted-unreads is@@ -388,7 +394,15 @@ class StreamSidebarRow {const stream_has_any_unread_mention_messages = unread.stream_has_any_unread_mentions(this.sub.stream_id,);- update_count_in_dom(this.$list_item, count, stream_has_any_unread_mention_messages);+ const stream_has_any_unmuted_unread_mention = unread.stream_has_any_unmuted_mentions(+ this.sub.stream_id,+ );+ update_count_in_dom(+ this.$list_item,+ count,+ stream_has_any_unread_mention_messages,+ stream_has_any_unmuted_unread_mention,+ );}}@@ -425,7 +439,12 @@ export function redraw_stream_privacy(sub) {$div.html(html);}-function set_stream_unread_count(stream_id, count, stream_has_any_unread_mention_messages) {+function set_stream_unread_count(+ stream_id,+ count,+ stream_has_any_unread_mention_messages,+ stream_has_any_unmuted_unread_mention,+) {const $stream_li = get_stream_li(stream_id);if (!$stream_li) {// This can happen for legitimate reasons, but we warn@@ -433,7 +452,12 @@ function set_stream_unread_count(stream_id, count, stream_has_any_unread_mentionblueslip.warn("stream id no longer in sidebar: " + stream_id);return;}- update_count_in_dom($stream_li, count, stream_has_any_unread_mention_messages);+ update_count_in_dom(+ $stream_li,+ count,+ stream_has_any_unread_mention_messages,+ stream_has_any_unmuted_unread_mention,+ );}export function update_streams_sidebar(force_rerender) {@@ -467,7 +491,14 @@ export function update_dom_with_unread_counts(counts) {for (const [stream_id, count] of counts.stream_count) {const stream_has_any_unread_mention_messages =counts.streams_with_mentions.includes(stream_id);- set_stream_unread_count(stream_id, count, stream_has_any_unread_mention_messages);+ const stream_has_any_unmuted_unread_mention =+ counts.streams_with_unmuted_mentions.includes(stream_id);+ set_stream_unread_count(+ stream_id,+ count,+ stream_has_any_unread_mention_messages,+ stream_has_any_unmuted_unread_mention,+ );}}diff --git a/web/src/unread.js b/web/src/unread.jsindex 7cac920f75b..c0370ad9adc 100644--- a/web/src/unread.js+++ b/web/src/unread.js@@ -438,6 +438,21 @@ class UnreadTopicCounter {return streams_with_mentions;}+ get_streams_with_unmuted_mentions() {+ const streams_with_unmuted_mentions = new Set();+ // Collect the set of streams containing at least one mention+ // in an unmuted topic within a muted stream.+ for (const message_id of unread_mentions_counter) {+ const stream_id = this.bucketer.reverse_lookup.get(message_id);+ const stream_bucketer = this.bucketer.get_bucket(stream_id);+ const topic = stream_bucketer.reverse_lookup.get(message_id);+ if (user_topics.is_topic_unmuted(stream_id, topic)) {+ streams_with_unmuted_mentions.add(stream_id);+ }+ }+ return streams_with_unmuted_mentions;+ }+topic_has_any_unread(stream_id, topic) {const per_stream_bucketer = this.bucketer.get_bucket(stream_id);@@ -730,9 +745,11 @@ export function get_counts() {// This sets stream_count, topic_count, and home_unread_messagesconst topic_res = unread_topic_counter.get_counts();const streams_with_mentions = unread_topic_counter.get_streams_with_unread_mentions();+ const streams_with_unmuted_mentions = unread_topic_counter.get_streams_with_unmuted_mentions();res.home_unread_messages = topic_res.stream_unread_messages;res.stream_count = topic_res.stream_count;res.streams_with_mentions = [...streams_with_mentions];+ res.streams_with_unmuted_mentions = [...streams_with_unmuted_mentions];const pm_res = unread_pm_counter.get_counts();res.pm_count = pm_res.pm_dict;@@ -786,6 +803,13 @@ export function stream_has_any_unread_mentions(stream_id) {return streams_with_mentions.has(stream_id);}+export function stream_has_any_unmuted_mentions(stream_id) {+ // This function is somewhat inefficient and thus should not be+ // called in loops, since runs in O(total unread mentions) time.+ const streams_with_mentions = unread_topic_counter.get_streams_with_unmuted_mentions();+ return streams_with_mentions.has(stream_id);+}+export function topic_has_any_unread_mentions(stream_id, topic) {// Because this function is called in a loop for every displayed// Recent Topics row, it's important for it to run in O(1) time.diff --git a/web/styles/dark_theme.css b/web/styles/dark_theme.cssindex b8f62882ddc..cfc375039ca 100644--- a/web/styles/dark_theme.css+++ b/web/styles/dark_theme.css@@ -32,6 +32,10 @@color: inherit;}+ .has-unmuted-mentions .unread_mention_info {+ color: hsl(236deg 33% 90%);+ }+& li.muted_topic,li.out_of_home_view {color: hsl(236deg 33% 90%/50%);diff --git a/web/styles/left_sidebar.css b/web/styles/left_sidebar.cssindex 0a088eedb7b..7b26c50068f 100644--- a/web/styles/left_sidebar.css+++ b/web/styles/left_sidebar.css@@ -338,6 +338,10 @@ ul.filters {li.out_of_home_view {color: hsl(0deg 0% 20% / 50%);+ .has-unmuted-mentions .unread_mention_info {+ color: hsl(0deg 0% 20%);+ }+.stream-privacy {opacity: 0.5;}diff --git a/web/tests/stream_list.test.js b/web/tests/stream_list.test.jsindex 4b3366be85c..a5c92d694f0 100644--- a/web/tests/stream_list.test.js+++ b/web/tests/stream_list.test.js@@ -15,6 +15,7 @@ page_params.realm_users = [];// We use this with override.let num_unread_for_stream;let stream_has_any_unread_mentions;+let stream_has_any_unmuted_mentions;const noop = () => {};mock_esm("../src/narrow_state", {@@ -35,6 +36,7 @@ mock_esm("../src/unread", {muted_count: 0,}),stream_has_any_unread_mentions: () => stream_has_any_unread_mentions,+ stream_has_any_unmuted_mentions: () => stream_has_any_unmuted_mentions,});const {Filter} = zrequire("../src/filter");