mirror of https://github.com/zulip/zulip.git
Fix message-edit animations being displayed after sending.
This fixes a regression in 3041480600
that would cause anything rendered on the backend differently than on
the frontend to experience this animation.
We actually only want to do the animation when the message content was
changed in a way that generates an edit history event, i.e. a
user-facing edit, not in cases where we're either transparently
swapping in post-backend-rendering content (e.g. with link previews)
or cases where there's a discrepancy between the exact HTML from the
frontend and backend markdown processes (e.g. mentions).
This commit is contained in:
parent
e7974b3b65
commit
7d8d9c1bf9
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
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);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue