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.

compose: Fix unresolve button for empty topics.

Kislay Verma454f2f2d95dc
diff --git a/web/src/compose_setup.js b/web/src/compose_setup.js
index 61d6c4ff499..25c8fcb4448 100644
--- a/web/src/compose_setup.js
+++ b/web/src/compose_setup.js
@@ -1,5 +1,6 @@
import $ from "jquery";
+import {unresolve_name} from "../shared/src/resolved_topic";
import render_add_poll_modal from "../templates/add_poll_modal.hbs";
import * as compose from "./compose";
@@ -168,7 +169,22 @@ export function initialize() {
const topic_name = $target.attr("data-topic-name");
message_edit.with_first_message_id(stream_id, topic_name, (message_id) => {
- message_edit.toggle_resolve_topic(message_id, topic_name, true);
+ if (message_id === undefined) {
+ // There is no message in the topic, so it is sufficient to
+ // just remove the topic resolved prefix (✔) from the topic name.
+ const $input = $("input#stream_message_recipient_topic");
+ const new_topic = unresolve_name(topic_name);
+ $input.val(new_topic);
+ // Trigger an input event, since this is a form of
+ // user-triggered edit to that field.
+ $input.trigger("input");
+
+ // TODO: Probably this should also renarrow to the
+ // new topic, if we were currently viewing the old
+ // topic, just as if a message edit had occurred.
+ } else {
+ message_edit.toggle_resolve_topic(message_id, topic_name, true);
+ }
compose_validate.clear_topic_resolved_warning(true);
});
},
diff --git a/web/src/message_edit.js b/web/src/message_edit.js
index a1895e900d3..a029de564dd 100644
--- a/web/src/message_edit.js
+++ b/web/src/message_edit.js
@@ -1375,7 +1375,7 @@ export function with_first_message_id(stream_id, topic_name, success_cb, error_c
url: "/json/messages",
data,
success(data) {
- const message_id = data.messages[0].id;
+ const message_id = data.messages[0]?.id;
success_cb(message_id);
},
error: error_cb,