Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic_list_data: Add support to filter empty string topic.
Prakhar Pratyusheed056a59117
diff --git a/web/src/topic_list_data.ts b/web/src/topic_list_data.tsindex 85dd5019dc6..b62c701c38f 100644--- a/web/src/topic_list_data.ts+++ b/web/src/topic_list_data.ts@@ -189,10 +189,11 @@ export function get_list_info(if (zoomed) {const word_separator_regex = /[\s/:_-]/; // Use -, _, :, / as word separators in addition to spaces.+ const empty_string_topic_display_name = util.get_final_topic_display_name("");topic_names = util.filter_by_word_prefix_match(topic_names,search_term,- (topic) => topic,+ (topic) => (topic === "" ? empty_string_topic_display_name : topic),word_separator_regex,);}diff --git a/web/tests/topic_list_data.test.cjs b/web/tests/topic_list_data.test.cjsindex def2b59f480..4d61ad996a1 100644--- a/web/tests/topic_list_data.test.cjs+++ b/web/tests/topic_list_data.test.cjs@@ -194,16 +194,23 @@ test("get_list_info w/real stream_topic_history", ({override}) => {assert.equal(list_info.num_possible_topics, 11);add_topic_message("After Brooklyn", 1008);- add_topic_message("Catering", 1009);+ add_topic_message("Delhi", 1009);// When topic search input is not empty, we show topics// based on the search term.- const search_term = "b,c";+ let search_term = "b,d";list_info = get_list_info(zoomed, search_term);assert.equal(list_info.items.length, 2);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, 2);++ // Verify empty string topic shows up for "general" search term.+ search_term = "general";+ list_info = get_list_info(zoomed, search_term);+ assert.equal(list_info.items.length, 1);+ assert.equal(list_info.items[0].topic_name, "");+ assert.equal(list_info.items[0].topic_display_name, REALM_EMPTY_TOPIC_DISPLAY_NAME);});test("get_list_info unreads", ({override}) => {