recent_topics: Standardize format of last message time.

We follow how other apps present older messages, e.g. Gmail,
Facebook Messenger, etc. display it.

Specifically, the logic we use is:

If the time is <24hr ago, show an absolute time, like "21:30" (or "9:30pm").
Otherwise, show what day it was, and not a time
  If the day was yesterday, say "Yesterday".
  Otherwise, if it was <7 days ago, say the day of week, like "Friday".
  Otherwise, if it was <1 year ago, say the month and day, like "Sep 6".
  Otherwise, say the year, month, and day, like "Sep 9, 2020".

With some tweaks from Tim Abbott to better handle the future case.

Fixes #19775
This commit is contained in:
Aman Agrawal
2022-02-09 13:59:51 +00:00
committed by Tim Abbott
parent c2a117c623
commit 27b985e868
4 changed files with 95 additions and 3 deletions

View File

@@ -253,7 +253,7 @@ function format_topic(topic_data) {
}
const topic = last_msg.topic;
const time = new Date(last_msg.timestamp * 1000);
const last_msg_time = timerender.last_seen_status_from_date(time);
const last_msg_time = timerender.format_time_modern(time);
const full_datetime = timerender.get_full_datetime(time);
// We hide the row according to filters or if it's muted.