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.

echo: Move topic links when locally editing a message's topic.

Aman Agrawalc8b5564b200e
diff --git a/web/src/echo.ts b/web/src/echo.ts
index 19084bddf18..f9097e4db4f 100644
--- a/web/src/echo.ts
+++ b/web/src/echo.ts
@@ -384,6 +384,11 @@ export function edit_locally(message: Message, request: LocalEditRequest): void
assert(message.type === "stream");
const new_stream_id = request.new_stream_id;
const new_topic = request.new_topic;
+ message_store.process_topic_edit({
+ message_ids: [message.id],
+ new_stream_id: new_stream_id ?? message.stream_id,
+ new_topic: new_topic ?? message.topic,
+ });
stream_topic_history.remove_messages({
stream_id: message.stream_id,
topic_name: message.topic,
diff --git a/web/tests/echo.test.cjs b/web/tests/echo.test.cjs
index 783ce484505..d938056841c 100644
--- a/web/tests/echo.test.cjs
+++ b/web/tests/echo.test.cjs
@@ -456,6 +456,37 @@ run_test("edit_locally recomputes content-driven booleans", ({override}) => {
assert.equal(message.mentioned_me_directly, false);
});
+run_test("edit_locally moves topic links with the message", ({override}) => {
+ override(stream_list, "update_streams_sidebar", noop);
+ override(pm_list, "update_private_messages", noop);
+ override(message_lists, "all_rendered_message_lists", () => [
+ {view: {rerender_messages: noop}},
+ ]);
+
+ const message = {
+ id: 43,
+ type: "stream",
+ stream_id: general_sub.stream_id,
+ topic: "old topic",
+ raw_content: "content",
+ };
+
+ let process_topic_edit_args;
+ override(message_store, "process_topic_edit", (opts) => {
+ process_topic_edit_args = {...opts, topic_at_call: message.topic};
+ });
+
+ echo.edit_locally(message, {new_topic: "new topic"});
+
+ assert.deepEqual(process_topic_edit_args, {
+ message_ids: [43],
+ new_stream_id: general_sub.stream_id,
+ new_topic: "new topic",
+ topic_at_call: "old topic",
+ });
+ assert.equal(message.topic, "new topic");
+});
+
run_test("test reify_message_id", ({override}) => {
const local_id_float = 103.01;