mirror of https://github.com/zulip/zulip.git
topic_list: Fix duplicate topic rows in left sidebar.
When narrowing to an existing topic name with different casing, left sidebar renders duplicate topic rows for the existing topic name and one with the different casing. Since topic names are case insensitive, it should narrow to the existing row only. Fixes regression from #29175.
This commit is contained in:
parent
d356577c29
commit
d3fbfeae31
|
@ -140,6 +140,11 @@ function choose_topics(
|
|||
}
|
||||
}
|
||||
|
||||
function contains_topic(topic_names: string[], narrowed_topic: string): boolean {
|
||||
const lower_cased_topics = topic_names.map((name) => name.toLowerCase());
|
||||
return lower_cased_topics.includes(narrowed_topic.toLowerCase());
|
||||
}
|
||||
|
||||
type TopicListInfo = {
|
||||
items: TopicInfo[];
|
||||
num_possible_topics: number;
|
||||
|
@ -174,7 +179,7 @@ export function get_list_info(
|
|||
if (
|
||||
stream_id === narrow_state.stream_id() &&
|
||||
narrowed_topic &&
|
||||
!topic_names.includes(narrowed_topic)
|
||||
!contains_topic(topic_names, narrowed_topic)
|
||||
) {
|
||||
topic_names.unshift(narrowed_topic);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue