mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
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:
@@ -434,6 +434,7 @@ exports.show_history = function (message) {
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
// For now, we ignore topic edits
|
// For now, we ignore topic edits
|
||||||
var content_edit_history = [];
|
var content_edit_history = [];
|
||||||
|
var prev_timestamp;
|
||||||
_.each(data.message_history, function (msg, index) {
|
_.each(data.message_history, function (msg, index) {
|
||||||
if (index !== 0 && !msg.prev_content) {
|
if (index !== 0 && !msg.prev_content) {
|
||||||
// Skip topic edits
|
// Skip topic edits
|
||||||
@@ -441,13 +442,20 @@ exports.show_history = function (message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format timestamp nicely for display
|
// 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) {
|
if (index === 0) {
|
||||||
item.posted_or_edited = "Posted by";
|
item.posted_or_edited = "Posted by";
|
||||||
item.body_to_render = msg.rendered_content;
|
item.body_to_render = msg.rendered_content;
|
||||||
|
prev_timestamp = timestamp;
|
||||||
|
item.show_date_row = true;
|
||||||
} else {
|
} else {
|
||||||
item.posted_or_edited = "Edited by";
|
item.posted_or_edited = "Edited by";
|
||||||
item.body_to_render = msg.content_html_diff;
|
item.body_to_render = msg.content_html_diff;
|
||||||
|
item.show_date_row = !moment(timestamp).isSame(prev_timestamp, 'day');
|
||||||
}
|
}
|
||||||
if (msg.user_id) {
|
if (msg.user_id) {
|
||||||
var person = people.get_person_from_user_id(msg.user_id);
|
var person = people.get_person_from_user_id(msg.user_id);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
{{! Client-side Mustache template for viewing message edit history.}}
|
{{! Client-side Mustache template for viewing message edit history.}}
|
||||||
|
|
||||||
<div class="date_row"><span id="timerender2">{{t 'Earliest' }}</span></div>
|
|
||||||
{{#each edited_messages}}
|
{{#each edited_messages}}
|
||||||
|
{{#if show_date_row}}
|
||||||
|
<div class="date_row"><span>{{ display_date }}</span></div>
|
||||||
|
{{/if}}
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="messagebox-border">
|
<div class="messagebox-border">
|
||||||
<div class="messagebox-content">
|
<div class="messagebox-content">
|
||||||
|
|||||||
Reference in New Issue
Block a user