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.

topic_list: Show topic row for empty conversations in left sidebar.

Pratik Chanda3f1ffd0068b8
diff --git a/web/src/topic_list_data.ts b/web/src/topic_list_data.ts
index 1ccd24aecfe..abf7e4be8eb 100644
--- a/web/src/topic_list_data.ts
+++ b/web/src/topic_list_data.ts
@@ -153,6 +153,7 @@ export function get_list_info(
zoomed: boolean,
search_term: string,
): TopicListInfo {
+ const narrowed_topic = narrow_state.topic();
const topic_choice_state: TopicChoiceState = {
items: [],
topics_selected: 0,
@@ -169,6 +170,15 @@ export function get_list_info(
const stream_muted = sub.is_muted;
let topic_names = stream_topic_history.get_recent_topic_names(stream_id);
+
+ if (
+ stream_id === narrow_state.stream_id() &&
+ narrowed_topic &&
+ !topic_names.includes(narrowed_topic)
+ ) {
+ topic_names.unshift(narrowed_topic);
+ }
+
if (zoomed) {
topic_names = util.filter_by_word_prefix_match(topic_names, search_term, (item) => item);
}
diff --git a/web/tests/topic_list_data.test.js b/web/tests/topic_list_data.test.js
index 909b68c8e30..4d96ecfb7c8 100644
--- a/web/tests/topic_list_data.test.js
+++ b/web/tests/topic_list_data.test.js
@@ -28,6 +28,7 @@ const user_topics = mock_esm("../src/user_topics", {
});
const narrow_state = mock_esm("../src/narrow_state", {
topic() {},
+ stream_id() {},
});
const stream_data = zrequire("stream_data");
@@ -86,6 +87,28 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
add_topic_message(topic_name + i, 1000 + i);
}
+ override(narrow_state, "topic", () => "topic 11");
+ override(narrow_state, "stream_id", () => 556);
+
+ list_info = get_list_info();
+ 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, 11);
+ assert.deepEqual(list_info.items[0], {
+ topic_name: "topic 11",
+ topic_resolved_prefix: "",
+ topic_display_name: "topic 11",
+ unread: 0,
+ is_zero: true,
+ is_muted: false,
+ is_followed: false,
+ is_unmuted_or_followed: false,
+ is_active_topic: true,
+ url: "#narrow/stream/556-general/topic/topic.2011",
+ contains_unread_mention: false,
+ });
+
override(narrow_state, "topic", () => "topic 6");
list_info = get_list_info();