Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic-list-data: Show the most recent umuted MAX_TOPICS.
Lauryn Menard1b340c6b74c5
diff --git a/web/src/topic_list_data.ts b/web/src/topic_list_data.tsindex c46861320a3..6107f7a52cd 100644--- a/web/src/topic_list_data.ts+++ b/web/src/topic_list_data.ts@@ -45,7 +45,7 @@ function choose_topics(zoomed: boolean,topic_choice_state: TopicChoiceState,): void {- for (const [idx, topic_name] of topic_names.entries()) {+ for (const topic_name of topic_names) {const num_unread = unread.num_unread_for_topic(stream_id, topic_name);const is_active_topic = topic_choice_state.active_topic === topic_name.toLowerCase();const is_topic_muted = user_topics.is_topic_muted(stream_id, topic_name);@@ -83,9 +83,9 @@ function choose_topics(return false;}- // We include the most recent MAX_TOPICS topics,+ // We include the most recent, unmuted MAX_TOPICS topics,// even if there are no unread messages.- if (idx < MAX_TOPICS && topics_selected < MAX_TOPICS) {+ if (topics_selected < MAX_TOPICS) {return true;}@@ -244,12 +244,11 @@ export function get_list_info(const unmuted_or_followed_topics = topic_names.filter((topic) =>user_topics.is_topic_unmuted_or_followed(stream_id, topic),);- choose_topics(stream_id, unmuted_or_followed_topics, zoomed, topic_choice_state);-const other_topics = topic_names.filter((topic) => !user_topics.is_topic_unmuted_or_followed(stream_id, topic),);- choose_topics(stream_id, other_topics, zoomed, topic_choice_state);+ const reordered_topics = [...unmuted_or_followed_topics, ...other_topics];+ choose_topics(stream_id, reordered_topics, zoomed, topic_choice_state);} else {choose_topics(stream_id, topic_names, zoomed, topic_choice_state);}diff --git a/web/tests/topic_list_data.test.cjs b/web/tests/topic_list_data.test.cjsindex cd8649233a4..0b9f0e95b68 100644--- a/web/tests/topic_list_data.test.cjs+++ b/web/tests/topic_list_data.test.cjs@@ -346,8 +346,9 @@ test("get_list_info unreads", ({override}) => {["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 5"],);- // If the most recent topics in the channel are- // all muted, then we show no topics.+ // We show the most recent, unmuted MAX_TOPICS+ // topics in the channel, whether they have+ // unread messages or not.override(user_topics, "is_topic_muted", (stream_id, topic_name) => {assert.equal(stream_id, general.stream_id);return ["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 5"].includes(@@ -356,13 +357,13 @@ test("get_list_info unreads", ({override}) => {});list_info = get_list_info();- assert.equal(list_info.items.length, 0);+ assert.equal(list_info.items.length, 6);assert.equal(list_info.more_topics_unreads, 0);assert.equal(list_info.more_topics_have_unread_mention_messages, false);assert.equal(list_info.num_possible_topics, 16);assert.deepEqual(list_info.items.map((li) => li.topic_name),- [],+ ["topic 6", "topic 7", "topic 8", "topic 9", "topic 10", "topic 11"],);override(user_topics, "is_topic_muted", () => false);