mirror of https://github.com/zulip/zulip.git
topic_list: Show topic row for empty conversations in left sidebar.
Earlier when a user narrowed to a new topic, there was no highlighted topic row entry in the left sidebar under the respective stream. This commit introduces the feature to show highlighted topic in the left sidebar for a new topic thread. It checks if narrowed topic is present in the list of topic names to add to it. It disappears from the left sidebar when unnarrowed and the topic contains no messages. Fixes: zulip#22769.
This commit is contained in:
parent
e1a63d57a2
commit
3f1ffd0068
|
@ -153,6 +153,7 @@ export function get_list_info(
|
||||||
zoomed: boolean,
|
zoomed: boolean,
|
||||||
search_term: string,
|
search_term: string,
|
||||||
): TopicListInfo {
|
): TopicListInfo {
|
||||||
|
const narrowed_topic = narrow_state.topic();
|
||||||
const topic_choice_state: TopicChoiceState = {
|
const topic_choice_state: TopicChoiceState = {
|
||||||
items: [],
|
items: [],
|
||||||
topics_selected: 0,
|
topics_selected: 0,
|
||||||
|
@ -169,6 +170,15 @@ export function get_list_info(
|
||||||
const stream_muted = sub.is_muted;
|
const stream_muted = sub.is_muted;
|
||||||
|
|
||||||
let topic_names = stream_topic_history.get_recent_topic_names(stream_id);
|
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) {
|
if (zoomed) {
|
||||||
topic_names = util.filter_by_word_prefix_match(topic_names, search_term, (item) => item);
|
topic_names = util.filter_by_word_prefix_match(topic_names, search_term, (item) => item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ const user_topics = mock_esm("../src/user_topics", {
|
||||||
});
|
});
|
||||||
const narrow_state = mock_esm("../src/narrow_state", {
|
const narrow_state = mock_esm("../src/narrow_state", {
|
||||||
topic() {},
|
topic() {},
|
||||||
|
stream_id() {},
|
||||||
});
|
});
|
||||||
|
|
||||||
const stream_data = zrequire("stream_data");
|
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);
|
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");
|
override(narrow_state, "topic", () => "topic 6");
|
||||||
|
|
||||||
list_info = get_list_info();
|
list_info = get_list_info();
|
||||||
|
|
Loading…
Reference in New Issue