message_edit_history: Add UI for seeing topic edits.

Users can previously see only message content edits, this will enable
them to see topic edits too in the same section, fixes #3731.

Fixes #3731.
This commit is contained in:
Nikhil-Vats
2019-02-22 19:38:16 +05:30
committed by Tim Abbott
parent 54915b76c7
commit 38be5ea743
6 changed files with 82 additions and 12 deletions

View File

@@ -550,34 +550,42 @@ exports.show_history = function (message) {
url: "/json/messages/" + message.id + "/history",
data: {message_id: JSON.stringify(message.id)},
success: function (data) {
// For now, we ignore topic edits
var content_edit_history = [];
var prev_timestamp;
_.each(data.message_history, function (msg, index) {
if (index !== 0 && !msg.prev_content) {
// Skip topic edits
return;
}
// Format timestamp nicely for display
var timestamp = timerender.get_full_time(msg.timestamp);
var item = {
timestamp: moment(timestamp).format("h:mm A"),
display_date: moment(timestamp).format("MMMM D, YYYY"),
};
if (msg.user_id) {
var person = people.get_person_from_user_id(msg.user_id);
item.edited_by = person.full_name;
}
if (index === 0) {
item.posted_or_edited = "Posted by";
item.body_to_render = msg.rendered_content;
prev_timestamp = timestamp;
item.show_date_row = true;
} else {
} else if (msg.prev_topic && msg.prev_content) {
item.posted_or_edited = "Edited by";
item.body_to_render = msg.content_html_diff;
item.show_date_row = !moment(timestamp).isSame(prev_timestamp, 'day');
item.topic_edited = true;
item.prev_topic = msg.prev_topic;
item.new_topic = msg.topic;
} else if (msg.prev_topic) {
item.posted_or_edited = "Topic edited by";
item.topic_edited = true;
item.prev_topic = msg.prev_topic;
item.new_topic = msg.topic;
} else {
// just a content edit
item.posted_or_edited = "Edited by";
item.body_to_render = msg.content_html_diff;
item.show_date_row = !moment(timestamp).isSame(prev_timestamp, 'day');
}
if (msg.user_id) {
var person = people.get_person_from_user_id(msg.user_id);
item.edited_by = person.full_name;
}
content_edit_history.push(item);