Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left-sidebar: Reduce max topics shown with and without unreads.
Lauryn Menard6710dd99d8a2
diff --git a/web/src/topic_list_data.ts b/web/src/topic_list_data.tsindex 3e2980d79cf..c46861320a3 100644--- a/web/src/topic_list_data.ts+++ b/web/src/topic_list_data.ts@@ -9,8 +9,8 @@ import * as unread from "./unread.ts";import * as user_topics from "./user_topics.ts";import * as util from "./util.ts";-const max_topics = 8;-const max_topics_with_unread = 12;+const MAX_TOPICS = 6;+const MAX_TOPICS_WITH_UNREAD = 10;export type TopicInfo = {stream_id: number;@@ -69,7 +69,7 @@ function choose_topics(// We always show the active topic. Ideally, this// logic would first check whether the active// topic is in the set of those with unreads to- // avoid ending up with max_topics_with_unread + 1+ // avoid ending up with MAX_TOPICS_WITH_UNREAD + 1// total topics if the active topic comes after// the first several topics with unread messages.if (is_active_topic) {@@ -83,16 +83,16 @@ function choose_topics(return false;}- // We include the most recent max_topics topics,+ // We include the most recent MAX_TOPICS topics,// even if there are no unread messages.- if (idx < max_topics && topics_selected < max_topics) {+ if (idx < MAX_TOPICS && topics_selected < MAX_TOPICS) {return true;}// We include older topics with unread messages up- // until max_topics_with_unread total topics have+ // until MAX_TOPICS_WITH_UNREAD total topics have// been included.- if (num_unread > 0 && topics_selected < max_topics_with_unread) {+ if (num_unread > 0 && topics_selected < MAX_TOPICS_WITH_UNREAD) {return true;}diff --git a/web/tests/topic_list_data.test.cjs b/web/tests/topic_list_data.test.cjsindex 56b397dfc7f..9c7fdc667e4 100644--- a/web/tests/topic_list_data.test.cjs+++ b/web/tests/topic_list_data.test.cjs@@ -155,7 +155,7 @@ test("get_list_info w/real stream_topic_history", ({override}) => {override(narrow_state, "stream_id", () => 556);list_info = get_list_info();- assert.equal(list_info.items.length, 8);+ 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, 11);@@ -181,7 +181,7 @@ test("get_list_info w/real stream_topic_history", ({override}) => {override(narrow_state, "topic", () => "topic 6");list_info = get_list_info();- assert.equal(list_info.items.length, 8);+ 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, 10);@@ -222,7 +222,7 @@ test("get_list_info w/real stream_topic_history", ({override}) => {add_topic_message("", 2025);list_info = get_list_info();- assert.equal(list_info.items.length, 8);+ 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, 11);@@ -244,7 +244,7 @@ test("get_list_info w/real stream_topic_history", ({override}) => {});// If we zoom in, our results are based on topic filter.- // If topic search input is empty, we show all 10 topics.+ // If topic search input is empty, we show all topics.const zoomed = true;list_info = get_list_info(zoomed);assert.equal(list_info.items.length, 11);@@ -336,11 +336,11 @@ test("get_list_info unreads", ({override}) => {/*We have 16 topics, but we only show up- to 12 topics, depending on how many have- unread counts. We only show a max of 8+ to 10 topics, depending on how many have+ unread counts. We only show a max of 6fully-read topics.- So first we'll get 10 topics, where 2 are+ So first we'll get 8 topics, where 2 areunread.*/add_unreads("topic 14", 1);@@ -355,25 +355,14 @@ test("get_list_info unreads", ({override}) => {add_unreads_with_mention("topic 14", 1);list_info = get_list_info();- assert.equal(list_info.items.length, 10);+ assert.equal(list_info.items.length, 8);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 0",- "topic 1",- "topic 2",- "topic 3",- "topic 4",- "topic 5",- "topic 6",- "topic 7",- "topic 13",- "topic 14",- ],+ ["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 5", "topic 13", "topic 14"],);add_unreads("topic 12", 1);@@ -381,7 +370,7 @@ test("get_list_info unreads", ({override}) => {add_unreads("topic 10", 1);list_info = get_list_info();- assert.equal(list_info.items.length, 12);+ assert.equal(list_info.items.length, 10);assert.equal(list_info.more_topics_unreads, 2);assert.equal(list_info.more_topics_have_unread_mention_messages, true);assert.equal(list_info.num_possible_topics, 16);@@ -395,8 +384,6 @@ test("get_list_info unreads", ({override}) => {"topic 3","topic 4","topic 5",- "topic 6",- "topic 7","topic 10","topic 11","topic 12",@@ -405,7 +392,6 @@ test("get_list_info unreads", ({override}) => {);add_unreads("topic 9", 1);- add_unreads("topic 8", 1);add_unreads("topic 4", 1);override(user_topics, "is_topic_muted", (stream_id, topic_name) => {@@ -423,7 +409,7 @@ test("get_list_info unreads", ({override}) => {});list_info = get_list_info();- assert.equal(list_info.items.length, 12);+ assert.equal(list_info.items.length, 10);assert.equal(list_info.more_topics_unreads, 3);assert.equal(list_info.more_topics_have_unread_mention_messages, true);assert.equal(list_info.num_possible_topics, 16);@@ -438,8 +424,6 @@ test("get_list_info unreads", ({override}) => {"topic 2","topic 3","topic 6",- "topic 7",- "topic 8","topic 9","topic 10","topic 11",@@ -447,13 +431,13 @@ test("get_list_info unreads", ({override}) => {],);- // Now test with topics 4/8/9, all the ones with unreads, being muted.+ // Now test with topics 4/9/10, all the ones with unreads, being muted.override(user_topics, "is_topic_muted", (stream_id, topic_name) => {assert.equal(stream_id, general.stream_id);- return ["topic 4", "topic 8", "topic 9"].includes(topic_name);+ return ["topic 4", "topic 9", "topic 10"].includes(topic_name);});list_info = get_list_info();- assert.equal(list_info.items.length, 12);+ assert.equal(list_info.items.length, 10);assert.equal(list_info.more_topics_unreads, 3);// Topic 14 now makes it above the "show all topics" fold.assert.equal(list_info.more_topics_have_unread_mention_messages, false);@@ -468,8 +452,6 @@ test("get_list_info unreads", ({override}) => {"topic 2","topic 3","topic 6",- "topic 7",- "topic 10","topic 11","topic 12","topic 13",@@ -477,9 +459,9 @@ test("get_list_info unreads", ({override}) => {],);- add_unreads_with_mention("topic 8", 1);+ add_unreads_with_mention("topic 9", 1);list_info = get_list_info();- assert.equal(list_info.items.length, 12);+ assert.equal(list_info.items.length, 10);assert.equal(list_info.more_topics_unreads, 4);// Topic 8's new mention gets counted here.assert.equal(list_info.more_topics_have_unread_mention_messages, true);@@ -494,8 +476,6 @@ test("get_list_info unreads", ({override}) => {"topic 2","topic 3","topic 6",- "topic 7",- "topic 10","topic 11","topic 12","topic 13",@@ -507,7 +487,7 @@ test("get_list_info unreads", ({override}) => {// result in just the unmuted unreads being counted.add_unreads("topic 15", 15);list_info = get_list_info();- assert.equal(list_info.items.length, 12);+ assert.equal(list_info.items.length, 10);assert.equal(list_info.more_topics_unreads, 15);assert.equal(list_info.more_topics_have_unread_mention_messages, true);assert.equal(list_info.num_possible_topics, 16);@@ -521,8 +501,6 @@ test("get_list_info unreads", ({override}) => {"topic 2","topic 3","topic 6",- "topic 7",- "topic 10","topic 11","topic 12","topic 13",