Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/packages/base/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
"commented_on_a_video": "Commented on a video",
"replied_to_a_comment": "Replied to a comment",
"liked_a_comment": "Liked a comment",
"just_now": "just now",
"minutes_ago": "{{count}}m ago",
"hours_ago": "{{count}}h ago",
"days_ago": "{{count}}d ago",
"like_anonymously": "Like anonymously",
"join_album_and_like": "Join album and like",
"keep_it_private": "Or keep it just between you and the memory.",
Expand Down
29 changes: 23 additions & 6 deletions web/packages/gallery/components/viewer/CommentsSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
deleteReaction,
} from "ente-new/photos/services/reaction";
import { type UnifiedReaction } from "ente-new/photos/services/social";
import { t } from "i18next";
import i18n, { t } from "i18next";
import React, {
useCallback,
useEffect,
Expand Down Expand Up @@ -180,14 +180,31 @@ interface CollectionInfo {
const formatTimeAgo = (timestampMicros: number): string => {
// Server timestamps are in microseconds, convert to milliseconds
const timestampMs = Math.floor(timestampMicros / 1000);
const diff = Date.now() - timestampMs;
const now = Date.now();
const diff = now - timestampMs;
const minutes = Math.floor(diff / 60000);
if (minutes < 1) return "now";
if (minutes < 60) return `${minutes}m ago`;
if (minutes < 1) return t("just_now");
if (minutes < 60) return t("minutes_ago", { count: minutes });
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours}h ago`;
if (hours < 24) return t("hours_ago", { count: hours });
const days = Math.floor(hours / 24);
return `${days}d ago`;
if (days < 7) return t("days_ago", { count: days });

// For 7+ days, show actual date using locale-aware formatting
const date = new Date(timestampMs);
const currentYear = new Date(now).getFullYear();
const locale = i18n.language;
if (date.getFullYear() === currentYear) {
return date.toLocaleDateString(locale, {
month: "short",
day: "numeric",
});
}
return date.toLocaleDateString(locale, {
month: "short",
day: "numeric",
year: "numeric",
});
};

const getParentComment = (
Expand Down