message-editing: Show date lines between edits from different days.

Added show_date_row field to each item of content_edit_history.
We use date lines to separate events that happened on different days.

Fixes #4638.
This commit is contained in:
Jack Zhang
2017-06-05 19:42:26 -07:00
committed by Tim Abbott
parent 0534a4c42d
commit 84e5fe733c
3 changed files with 21 additions and 11 deletions

View File

@@ -434,6 +434,7 @@ exports.show_history = function (message) {
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
@@ -441,13 +442,20 @@ exports.show_history = function (message) {
}
// Format timestamp nicely for display
var item = {timestamp: moment(timerender.get_full_time(msg.timestamp)).format("h:mm A")};
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 (index === 0) {
item.posted_or_edited = "Posted by";
item.body_to_render = msg.rendered_content;
prev_timestamp = timestamp;
item.show_date_row = true;
} else {
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);

View File

@@ -1,7 +1,9 @@
{{! Client-side Mustache template for viewing message edit history.}}
<div class="date_row"><span id="timerender2">{{t 'Earliest' }}</span></div>
{{#each edited_messages}}
{{#if show_date_row}}
<div class="date_row"><span>{{ display_date }}</span></div>
{{/if}}
<div class="">
<div class="messagebox-border">
<div class="messagebox-content">