mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +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) {
|
||||
// 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);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
{{! Client-side Mustache template for viewing message edit history.}}
|
||||
|
||||
<div class="date_row"><span id="timerender2">{{t 'Earliest' }}</span></div>
|
||||
{{#each edited_messages}}
|
||||
<div class="">
|
||||
{{#if show_date_row}}
|
||||
<div class="date_row"><span>{{ display_date }}</span></div>
|
||||
{{/if}}
|
||||
<div class="">
|
||||
<div class="messagebox-border">
|
||||
<div class="messagebox-content">
|
||||
<div class="message_top_line"><span class="message_time">{{ timestamp }}</span></div>
|
||||
@@ -10,6 +12,6 @@
|
||||
<div class="message_author"><div class="author_details">{{ posted_or_edited }} {{ edited_by }}</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</div>
|
||||
<hr/>
|
||||
{{/each}}
|
||||
|
||||
Reference in New Issue
Block a user