diff --git a/frontend/src/ts/pages/friends.ts b/frontend/src/ts/pages/friends.ts
index c430c2399..e1366fb22 100644
--- a/frontend/src/ts/pages/friends.ts
+++ b/frontend/src/ts/pages/friends.ts
@@ -6,7 +6,8 @@ import {
intervalToDuration,
format as dateFormat,
formatDuration,
- DurationUnit,
+ formatDistanceToNow,
+ format,
} from "date-fns";
import * as Notifications from "../elements/notifications";
import { isSafeNumber } from "@monkeytype/util/numbers";
@@ -173,7 +174,14 @@ function updatePendingConnections(): void {
${item.initiatorName} |
- ${formatAge(item.lastModified)} ago |
+
+
+ ${formatAge(item.lastModified)}
+
+ |
|
- ${
+ |
+ ? format(entry.lastModified, "dd MMM yyyy HH:mm")
+ : ""
+ }">${
+ entry.lastModified !== undefined
+ ? formatAge(entry.lastModified, "short")
+ : "-"
+ } |
@@ -320,28 +332,16 @@ function formatAge(
timestamp: number | undefined,
format?: "short" | "full"
): string {
- const units: Array = [
- "years",
- "months",
- "days",
- "hours",
- "minutes",
- ];
-
if (timestamp === undefined) return "";
let formatted = "";
const duration = intervalToDuration({ start: timestamp, end: Date.now() });
if (format === undefined || format === "full") {
- formatted = formatDuration(duration, { format: units });
+ formatted = formatDuration(duration, {
+ format: ["years", "months", "days", "hours", "minutes"],
+ });
} else {
- for (const unit of units) {
- const value = duration[unit];
- if (value !== undefined && value > 0) {
- formatted = `${value} ${unit}`;
- break;
- }
- }
+ formatted = formatDistanceToNow(timestamp);
}
return formatted !== "" ? formatted : "less then a minute";
|