From d529013b9ae52ff9b988e7fbc053ef846d87cc6e Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Tue, 20 Aug 2013 11:00:55 -0400 Subject: [PATCH] Fix browser error in editing PMs. PMs do not have a "topic" field. (imported from commit 023d283ad94147e8bb9a2c7f6959c0a636d825cd) --- static/js/message_edit.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/static/js/message_edit.js b/static/js/message_edit.js index 1cb23eb066..324502fe6a 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -7,18 +7,23 @@ var currently_editing_messages = {}; exports.save = function (row) { var msg_list = current_msg_list; var message = current_msg_list.get(rows.id(row)); - var new_topic = row.find(".message_edit_topic").val(); - var new_content = row.find(".message_edit_content").val(); + var changed = false; var request = {message_id: message.id}; - if (new_topic !== message.subject && new_topic.trim() !== "") { - request.subject = new_topic; + if (message.type === "stream") { + var new_topic = row.find(".message_edit_topic").val(); + if (new_topic !== message.subject && new_topic.trim() !== "") { + request.subject = new_topic; + changed = true; + } } + + var new_content = row.find(".message_edit_content").val(); if (new_content !== message.raw_content) { request.content = new_content; + changed = true; } - if (request.subject === undefined && - request.content === undefined) { + if (!changed) { // If they didn't change anything, just cancel it. return true; }