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_popover: Show topic links with the topic's actual case.

Aman Agrawala6249fead6b5
diff --git a/web/src/stream_topic_history.ts b/web/src/stream_topic_history.ts
index c0eb8a3edd7..c89df347d0b 100644
--- a/web/src/stream_topic_history.ts
+++ b/web/src/stream_topic_history.ts
@@ -392,6 +392,10 @@ export function get_latest_known_message_id_in_topic(
return history?.topics.get(topic_name)?.message_id;
}
+export function get_known_topic_name(stream_id: number, topic_name: string): string | undefined {
+ return stream_dict.get(stream_id)?.topics.get(topic_name)?.pretty_name;
+}
+
// We use the topic permalinks if we have access to the last message
// id of the topic in the cache, by encoding it at the end of the
// traditional channel-topic url using a `with` operator. If client
diff --git a/web/src/topic_popover.ts b/web/src/topic_popover.ts
index a787e3c4988..689ad528ba1 100644
--- a/web/src/topic_popover.ts
+++ b/web/src/topic_popover.ts
@@ -78,9 +78,11 @@ function get_cross_conversation_link_render_context(link: message_store.TopicLin
is_empty_string_topic: boolean;
is_message_link: boolean;
} {
+ const topic_name =
+ stream_topic_history.get_known_topic_name(link.stream_id, link.topic) ?? link.topic;
const {url} = topic_link_util.get_topic_link_content_with_stream_id({
stream_id: link.stream_id,
- topic_name: link.topic,
+ topic_name,
message_id: link.message_id?.toString(),
});
const stream = stream_data.get_sub_by_id(link.stream_id);
@@ -89,8 +91,8 @@ function get_cross_conversation_link_render_context(link: message_store.TopicLin
stream,
channel_id: link.stream_id,
channel_name: stream?.name ?? "",
- topic_display_name_html: _.escape(util.get_final_topic_display_name(link.topic)),
- is_empty_string_topic: link.topic === "",
+ topic_display_name_html: _.escape(util.get_final_topic_display_name(topic_name)),
+ is_empty_string_topic: topic_name === "",
is_message_link: link.message_id !== undefined,
};
}
diff --git a/web/tests/stream_topic_history.test.cjs b/web/tests/stream_topic_history.test.cjs
index b8945c00633..85e30e7eb1b 100644
--- a/web/tests/stream_topic_history.test.cjs
+++ b/web/tests/stream_topic_history.test.cjs
@@ -362,6 +362,22 @@ test("update_topic_name_case", () => {
assert.deepEqual(stream_topic_history.get_recent_topic_names(stream_id), ["Known Topic"]);
});
+test("get_known_topic_name", () => {
+ const stream_id = 91;
+ assert.equal(stream_topic_history.get_known_topic_name(stream_id, "known topic"), undefined);
+
+ stream_topic_history.add_message({
+ stream_id,
+ message_id: 910,
+ topic_name: "Known Topic",
+ });
+ assert.equal(
+ stream_topic_history.get_known_topic_name(stream_id, "KNOWN topic"),
+ "Known Topic",
+ );
+ assert.equal(stream_topic_history.get_known_topic_name(stream_id, "other topic"), undefined);
+});
+
test("server_history_end_to_end", () => {
stream_topic_history.reset();