mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
message_edit: Don't send content to server if msg edit is disabled.
We ensure that if message edit is disabled, then we don't send content in request to the server. Refactored by tabbott to match the existing pattern for how we do this for topic/stream edits.
This commit is contained in:
@@ -880,7 +880,11 @@ export function save_message_row_edit($row) {
|
||||
let changed = false;
|
||||
let edit_locally_echoed = false;
|
||||
|
||||
const new_content = $row.find(".message_edit_content").val();
|
||||
const $edit_content_input = $row.find(".message_edit_content");
|
||||
let content_changed = false;
|
||||
let new_content;
|
||||
const old_content = message.raw_content;
|
||||
|
||||
let topic_changed = false;
|
||||
let new_topic;
|
||||
const old_topic = message.topic;
|
||||
@@ -891,6 +895,12 @@ export function save_message_row_edit($row) {
|
||||
|
||||
show_message_edit_spinner($row);
|
||||
|
||||
if ($edit_content_input.attr("readonly") !== "readonly") {
|
||||
new_content = $edit_content_input.val();
|
||||
content_changed = old_content !== new_content;
|
||||
changed = content_changed;
|
||||
}
|
||||
|
||||
if (message.type === "stream") {
|
||||
new_topic = $row.find(".message_edit_topic").val();
|
||||
topic_changed = new_topic !== old_topic && new_topic.trim() !== "";
|
||||
@@ -942,9 +952,8 @@ export function save_message_row_edit($row) {
|
||||
if (stream_changed) {
|
||||
request.stream_id = new_stream_id;
|
||||
}
|
||||
if (new_content !== message.raw_content) {
|
||||
if (content_changed) {
|
||||
request.content = new_content;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!changed) {
|
||||
|
||||
Reference in New Issue
Block a user