mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
refactor: Remove today arg from render_date and use MockDate for tests.
Fixes #26774. We don't need the today argument anymore since every value passed to it was a new Date() except the tests where we are using MockDate now.
This commit is contained in:
committed by
Tim Abbott
parent
a15d4e2be7
commit
3a233d73c1
@@ -118,8 +118,7 @@ function analyze_edit_history(message, last_edit_timestr) {
|
||||
|
||||
function render_group_display_date(group, message_container) {
|
||||
const time = new Date(message_container.msg.timestamp * 1000);
|
||||
const today = new Date();
|
||||
const date_element = timerender.render_date(time, today)[0];
|
||||
const date_element = timerender.render_date(time)[0];
|
||||
|
||||
group.date = date_element.outerHTML;
|
||||
}
|
||||
@@ -151,10 +150,9 @@ function update_message_date_divider(opts) {
|
||||
}
|
||||
|
||||
const curr_time = new Date(curr_msg_container.msg.timestamp * 1000);
|
||||
const today = new Date();
|
||||
|
||||
curr_msg_container.want_date_divider = true;
|
||||
curr_msg_container.date_divider_html = timerender.render_date(curr_time, today)[0].outerHTML;
|
||||
curr_msg_container.date_divider_html = timerender.render_date(curr_time)[0].outerHTML;
|
||||
}
|
||||
|
||||
function set_timestr(message_container) {
|
||||
@@ -327,8 +325,7 @@ export class MessageListView {
|
||||
}
|
||||
if (last_edit_timestamp !== undefined) {
|
||||
const last_edit_time = new Date(last_edit_timestamp * 1000);
|
||||
const today = new Date();
|
||||
let date = timerender.render_date(last_edit_time, today)[0].textContent;
|
||||
let date = timerender.render_date(last_edit_time)[0].textContent;
|
||||
// If the date is today or yesterday, we don't want to show the date as capitalized.
|
||||
// Thus, we need to check if the date string contains a digit or not using regex,
|
||||
// since any other date except today/yesterday will contain a digit.
|
||||
@@ -1640,8 +1637,7 @@ export class MessageListView {
|
||||
}
|
||||
this.sticky_recipient_message_id = message.id;
|
||||
const time = new Date(message.timestamp * 1000);
|
||||
const today = new Date();
|
||||
const rendered_date = timerender.render_date(time, undefined, today);
|
||||
const rendered_date = timerender.render_date(time);
|
||||
$sticky_header.find(".recipient_row_date").html(rendered_date);
|
||||
|
||||
// The following prevents a broken looking situation where
|
||||
|
||||
Reference in New Issue
Block a user