diff --git a/static/js/message_events.js b/static/js/message_events.js index c2097229b7..2240b396b9 100644 --- a/static/js/message_events.js +++ b/static/js/message_events.js @@ -111,6 +111,7 @@ exports.update_messages = function update_messages(events) { var msgs_to_rerender = []; var topic_edited = false; var changed_narrow = false; + var message_content_edited = false; _.each(events, function (event) { var msg = message_store.get(event.message_id); @@ -213,6 +214,7 @@ exports.update_messages = function update_messages(events) { msg.edit_history = []; } msg.edit_history = [edit_history_entry].concat(msg.edit_history); + message_content_edited = true; } msg.last_edit_timestamp = event.edit_timestamp; @@ -233,9 +235,10 @@ exports.update_messages = function update_messages(events) { message_list.narrowed.rerender(); } } else { - home_msg_list.view.rerender_messages(msgs_to_rerender); + // If the content of the message was edited, we do a special animation. + current_msg_list.view.rerender_messages(msgs_to_rerender, message_content_edited); if (current_msg_list === message_list.narrowed) { - message_list.narrowed.view.rerender_messages(msgs_to_rerender); + home_msg_list.view.rerender_messages(msgs_to_rerender); } } unread_ui.update_unread_counts(); diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index fccb1a299d..8a083e6162 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -812,7 +812,8 @@ MessageListView.prototype = { header.replaceWith(rendered_recipient_row); }, - _rerender_message: function MessageListView___rerender_message(message_container) { + _rerender_message: function MessageListView___rerender_message(message_container, + message_content_edited) { var row = this.get_row(message_container.msg.id); var was_selected = this.list.selected_message() === message_container.msg; @@ -821,7 +822,9 @@ MessageListView.prototype = { this._maybe_format_me_message(message_container); var rendered_msg = $(this._get_message_template(message_container)); - rendered_msg.addClass("fade-in-message"); + if (message_content_edited) { + rendered_msg.addClass("fade-in-message"); + } this._post_process_dom_messages(rendered_msg.get()); row.replaceWith(rendered_msg); @@ -830,7 +833,8 @@ MessageListView.prototype = { } }, - rerender_messages: function MessageListView__rerender_messages(messages) { + rerender_messages: function MessageListView__rerender_messages(messages, + message_content_edited) { var self = this; // Convert messages to list messages @@ -852,13 +856,13 @@ MessageListView.prototype = { message_groups.push(current_group); current_group = []; } - self._rerender_message(message_container); + self._rerender_message(message_container, message_content_edited); }); if (current_group.length !== 0) { message_groups.push(current_group); } _.each(message_groups, function (messages_in_group) { - self._rerender_header(messages_in_group); + self._rerender_header(messages_in_group, message_content_edited); }); },