mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
topic_list_data: Add support to filter empty string topic.
We show `realm_empty_topic_display_name` for empty string topics in the left sidebar. This commit makes it possible for users to search for the `realm_empty_topic_display_name` value to filter out empty string topics.
This commit is contained in:
committed by
Tim Abbott
parent
6ac9e3328e
commit
eed056a591
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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}) => {
|
||||
|
||||
Reference in New Issue
Block a user