Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_events: Fix edit history live update when moving topics.
Tim Abbott36f03ccd5c8f
diff --git a/static/js/message_events.js b/static/js/message_events.jsindex 230473f1510..0aa51fa054b 100644--- a/static/js/message_events.js+++ b/static/js/message_events.js@@ -222,6 +222,25 @@ export function update_messages(events) {}for (const msg of event_messages) {+ if (page_params.realm_allow_edit_history) {+ /* Simulate the format of server-generated edit+ * history events. This logic ensures that all+ * messages that were moved are displayed as such+ * without a browser reload. */+ const edit_history_entry = {+ edited_by: event.edited_by,+ prev_topic: orig_topic,+ prev_stream: event.stream_id,+ timestamp: event.edit_timestamp,+ };+ if (msg.edit_history === undefined) {+ msg.edit_history = [];+ }+ msg.edit_history = [edit_history_entry].concat(msg.edit_history);+ }+ msg.last_edit_timestamp = event.edit_timestamp;+ delete msg.last_edit_timestr;+// Remove the recent topics entry for the old topics;// must be called before we call set_message_topic.//@@ -348,9 +367,9 @@ export function update_messages(events) {if (event.orig_content !== undefined) {if (page_params.realm_allow_edit_history) {- // Most correctly, we should do this for topic edits as- // well; but we don't use the data except for content- // edits anyway.+ // Note that we do this for topic edits separately, above.+ // If an event changed both content and topic, we'll generate+ // two client-side events, which is probably good for display.const edit_history_entry = {edited_by: event.edited_by,prev_content: event.orig_content,