Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

recent_view: Use minutes short form to avoid wrapping time.

Aman Agrawal75a84724110e
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts
index 86910acc496..ba00f4fa712 100644
--- a/web/src/recent_view_ui.ts
+++ b/web/src/recent_view_ui.ts
@@ -655,7 +655,7 @@ function format_conversation(conversation_data: ConversationData): ConversationC
const full_last_msg_date_time = timerender.get_full_datetime_clarification(time);
const conversation_key = recent_view_util.get_key_from_message(last_msg);
const unread_count = message_to_conversation_unread_count(last_msg);
- const last_msg_time = timerender.relative_time_string_from_date(time);
+ const last_msg_time = timerender.relative_time_string_from_date(time, true);
const is_private = last_msg.type === "private";
let all_senders;
@@ -1390,7 +1390,7 @@ export function update_recent_view_rendered_time(): void {
const last_msg = message_store.get(conversation_data.last_msg_id);
assert(last_msg !== undefined);
const time = new Date(last_msg.timestamp * 1000);
- const updated_time = timerender.relative_time_string_from_date(time);
+ const updated_time = timerender.relative_time_string_from_date(time, true);
const $row = get_topic_row(conversation_data);
const rendered_time = $row.find(".recent_topic_timestamp").text().trim();
if (updated_time === rendered_time) {
diff --git a/web/src/timerender.ts b/web/src/timerender.ts
index defbcef725a..6b16113e8b0 100644
--- a/web/src/timerender.ts
+++ b/web/src/timerender.ts
@@ -221,13 +221,17 @@ export function render_now(time: Date, today = new Date(), display_year?: boolea
}
// Relative time rendering for use in most screens like Recent conversations.
-export function relative_time_string_from_date(date: Date): string {
+export function relative_time_string_from_date(date: Date, use_minutes_short_form = false): string {
const current_date = new Date();
const minutes = differenceInMinutes(current_date, date);
if (minutes <= 2) {
return $t({defaultMessage: "Just now"});
}
if (minutes < 60) {
+ if (use_minutes_short_form) {
+ return $t({defaultMessage: "{minutes} min ago"}, {minutes});
+ }
+
return $t({defaultMessage: "{minutes} minutes ago"}, {minutes});
}