π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add social photo viewer
Anand Baburajan3af285a87388
diff --git a/web/apps/social/package.json b/web/apps/social/package.jsonindex 00ee4f18e9..2466e4b345 100644--- a/web/apps/social/package.json+++ b/web/apps/social/package.json@@ -5,7 +5,8 @@"dependencies": {"@hugeicons/core-free-icons": "^1.1.0","@hugeicons/react": "^1.1.4",- "ente-base": "*"+ "ente-base": "*",+ "photoswipe": "^5.4.4"},"devDependencies": {"ente-build-config": "*"diff --git a/web/apps/social/src/components/SocialFileViewer.tsx b/web/apps/social/src/components/SocialFileViewer.tsxnew file mode 100644index 0000000000..1d7727caeb--- /dev/null+++ b/web/apps/social/src/components/SocialFileViewer.tsx@@ -0,0 +1,407 @@+import {+ Cancel01Icon,+ Comment01Icon,+ FavouriteIcon,+} from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { Box } from "@mui/material";+import type PhotoSwipe from "photoswipe";+import React from "react";+import {+ firstNameFrom,+ formatSocialDate,+ initialsFor,+} from "utils/socialDisplay";++const green = "#08C225";+const paleGreen = "#E7F6E9";+const textBase = "#F4F4F4";+const textSecondary = "#A6A6A6";+const viewerBackground = "#000000";+const controlBackground = "rgba(36, 36, 36, 0.72)";+const controlBackgroundHover = "rgba(48, 48, 48, 0.86)";+const closeControlBackground = "#242424";+const controlIcon = "#D8D8D8";+const viewerHeaderHeight = 56;+const viewerBottomPadding = 72;+const defaultPhotoWidth = 900;+const defaultPhotoHeight = 680;++export interface SocialViewerPhoto {+ alt?: string;+ avatarUrl?: string | null;+ height?: number;+ imageUrl: string;+ name: string;+ timestampMs: number;+ width?: number;+}++interface SocialFileViewerProps {+ onClose: () => void;+ photo: SocialViewerPhoto;+}++const viewerActionButtonSx = {+ alignItems: "center",+ bgcolor: controlBackground,+ border: 0,+ borderRadius: "50%",+ boxShadow: "0 10px 28px rgba(0, 0, 0, 0.36)",+ color: controlIcon,+ cursor: "pointer",+ display: "flex",+ height: 48,+ justifyContent: "center",+ p: 0,+ transition: "background-color 120ms ease, transform 120ms ease",+ width: 48,+ "&:active": { bgcolor: "#3A3A3A", transform: "scale(0.96)" },+ "&:focus-visible": { outline: `2px solid ${green}`, outlineOffset: 2 },+ "&:hover": { bgcolor: controlBackgroundHover },+};++export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({+ onClose,+ photo,+}) => {+ const displayName = firstNameFrom(photo.name);+ const dateLabel = formatSocialDate(photo.timestampMs);+ const initials = initialsFor(photo.name);+ const viewerRootRef = React.useRef<HTMLDivElement | null>(null);++ React.useEffect(() => {+ const root = viewerRootRef.current;+ if (!root) return;++ let disposed = false;+ let closedByReact = false;+ let pswp: PhotoSwipe | undefined;++ void import("photoswipe").then(({ default: PhotoSwipeClass }) => {+ if (disposed || !viewerRootRef.current) return;++ pswp = new PhotoSwipeClass({+ allowPanToNext: false,+ appendToEl: viewerRootRef.current,+ arrowKeys: false,+ arrowNext: false,+ arrowPrev: false,+ bgClickAction: false,+ bgOpacity: 1,+ clickToCloseNonZoomable: false,+ close: false,+ closeOnVerticalDrag: false,+ counter: false,+ dataSource: [+ {+ alt: photo.alt ?? `${photo.name} post`,+ height: photo.height ?? defaultPhotoHeight,+ src: photo.imageUrl,+ width: photo.width ?? defaultPhotoWidth,+ },+ ],+ doubleTapAction: "zoom",+ errorMsg: "Unable to preview this photo",+ escKey: false,+ imageClickAction: "zoom",+ index: 0,+ loop: false,+ mainClass: "pswp-social-viewer",+ maxZoomLevel: 4,+ paddingFn: () => ({+ bottom: viewerBottomPadding,+ left: 0,+ right: 0,+ top: viewerHeaderHeight,+ }),+ pinchToClose: false,+ returnFocus: false,+ secondaryZoomLevel: 2,+ showHideAnimationType: "none",+ spacing: 0,+ tapAction: false,+ trapFocus: false,+ wheelToZoom: true,+ zoom: false,+ });+ pswp.on("close", () => {+ if (!closedByReact) onClose();+ });+ pswp.init();+ });++ return () => {+ disposed = true;+ closedByReact = true;+ pswp?.destroy();+ };+ }, [+ onClose,+ photo.alt,+ photo.height,+ photo.imageUrl,+ photo.name,+ photo.width,+ ]);++ React.useEffect(() => {+ if (typeof document == "undefined") return;++ const previousOverflow = document.body.style.overflow;+ document.body.style.overflow = "hidden";+ return () => {+ document.body.style.overflow = previousOverflow;+ };+ }, []);++ React.useEffect(() => {+ const closeOnEscape = (event: KeyboardEvent) => {+ if (event.key == "Escape") onClose();+ };++ window.addEventListener("keydown", closeOnEscape);+ return () => window.removeEventListener("keydown", closeOnEscape);+ }, [onClose]);++ return (+ <Box+ ref={viewerRootRef}+ role="dialog"+ aria-label={`${displayName} photo viewer`}+ aria-modal="true"+ sx={{+ bgcolor: viewerBackground,+ color: textBase,+ display: "flex",+ flexDirection: "column",+ inset: 0,+ isolation: "isolate",+ minHeight: "100svh",+ overflow: "hidden",+ position: "fixed",+ width: "100vw",+ zIndex: 1300,+ }}+ >+ <Box+ component="header"+ sx={{+ alignItems: "center",+ display: "grid",+ flexShrink: 0,+ gap: "12px",+ gridTemplateColumns: "minmax(0, 1fr) 40px",+ minHeight: viewerHeaderHeight,+ position: "relative",+ px: "16px",+ width: "100%",+ zIndex: 2,+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ display: "flex",+ gap: "10px",+ minWidth: 0,+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ bgcolor: photo.avatarUrl+ ? "transparent"+ : paleGreen,+ borderRadius: "50%",+ color: green,+ display: "flex",+ flexShrink: 0,+ height: 32,+ justifyContent: "center",+ overflow: "hidden",+ width: 32,+ }}+ >+ {photo.avatarUrl ? (+ <Box+ component="img"+ alt=""+ src={photo.avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ ) : (+ <Box+ sx={{+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 11,+ fontWeight: 800,+ lineHeight: 1,+ }}+ >+ {initials}+ </Box>+ )}+ </Box>+ <Box+ sx={{+ alignItems: "baseline",+ display: "flex",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ gap: "4px",+ lineHeight: "20px",+ minWidth: 0,+ overflow: "hidden",+ whiteSpace: "nowrap",+ }}+ >+ <Box+ component="span"+ sx={{+ fontWeight: 650,+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ }}+ >+ {displayName}+ </Box>+ <Box+ component="span"+ aria-hidden+ sx={{+ color: textSecondary,+ flexShrink: 0,+ fontWeight: 500,+ }}+ >+ Β·+ </Box>+ <Box+ component="time"+ dateTime={new Date(photo.timestampMs).toISOString()}+ sx={{+ color: textSecondary,+ flexShrink: 0,+ fontSize: 12,+ fontWeight: 500,+ }}+ >+ {dateLabel}+ </Box>+ </Box>+ </Box>+ <Box+ component="button"+ type="button"+ aria-label="Close viewer"+ onClick={onClose}+ sx={{+ alignItems: "center",+ bgcolor: closeControlBackground,+ border: 0,+ borderRadius: "50%",+ color: controlIcon,+ cursor: "pointer",+ display: "flex",+ height: 28,+ justifyContent: "center",+ justifySelf: "flex-end",+ p: 0,+ width: 28,+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": { bgcolor: controlBackgroundHover },+ }}+ >+ <HugeiconsIcon+ icon={Cancel01Icon}+ size={18}+ strokeWidth={1.8}+ />+ </Box>+ </Box>+ <Box+ sx={{+ flex: "1 1 auto",+ minHeight: 0,+ position: "relative",+ width: "100%",+ }}+ />+ <Box+ aria-hidden+ sx={{+ background:+ "linear-gradient(180deg, rgba(0, 0, 0, 0.42) 0%, rgba(0, 0, 0, 0) 100%)",+ height: 112,+ left: 0,+ pointerEvents: "none",+ position: "fixed",+ right: 0,+ top: 0,+ zIndex: 1,+ }}+ />+ <Box+ aria-hidden+ sx={{+ background:+ "linear-gradient(0deg, rgba(0, 0, 0, 0.48) 0%, rgba(0, 0, 0, 0) 100%)",+ bottom: 0,+ height: 140,+ left: 0,+ pointerEvents: "none",+ position: "fixed",+ right: 0,+ zIndex: 1,+ }}+ />+ <Box+ sx={{+ bottom: "16px",+ display: "flex",+ gap: "10px",+ position: "fixed",+ right: "16px",+ zIndex: 2,+ }}+ >+ <Box+ component="button"+ type="button"+ aria-label="Like photo"+ sx={viewerActionButtonSx}+ >+ <HugeiconsIcon+ icon={FavouriteIcon}+ size={26}+ strokeWidth={1.8}+ />+ </Box>+ <Box+ component="button"+ type="button"+ aria-label="Comment on photo"+ sx={viewerActionButtonSx}+ >+ <HugeiconsIcon+ icon={Comment01Icon}+ size={26}+ strokeWidth={1.8}+ />+ </Box>+ </Box>+ </Box>+ );+};diff --git a/web/apps/social/src/pages/_app.tsx b/web/apps/social/src/pages/_app.tsxindex b951190b16..8ae288bc8d 100644--- a/web/apps/social/src/pages/_app.tsx+++ b/web/apps/social/src/pages/_app.tsx@@ -1,12 +1,13 @@import "@fontsource-variable/inter";-import "styles/globals.css";import { CssBaseline } from "@mui/material";import { ThemeProvider } from "@mui/material/styles";import { CustomHead } from "ente-base/components/Head";import { useSetupLogs } from "ente-base/components/utils/hooks-app";import { shareTheme } from "ente-base/components/utils/theme";import type { AppProps } from "next/app";+import "photoswipe/dist/photoswipe.css";import React from "react";+import "styles/globals.css";const App: React.FC<AppProps> = ({ Component, pageProps }) => {useSetupLogs({ disableDiskLogs: true });diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsxindex d0878c1386..2fa5dedc71 100644--- a/web/apps/social/src/screens/HomeScreen.tsx+++ b/web/apps/social/src/screens/HomeScreen.tsx@@ -1,7 +1,12 @@import { Box } from "@mui/material";+import {+ SocialFileViewer,+ type SocialViewerPhoto,+} from "components/SocialFileViewer";import { EnteLogo } from "ente-base/components/EnteLogo";-import React from "react";+import React, { useState } from "react";import type { SetupProfile } from "screens/SetupProfileScreen";+import { firstNameFrom, formatSocialDate } from "utils/socialDisplay";export const homeBackground = "#FFFFFF";@@ -13,45 +18,53 @@ const textSecondary = "#6B6B6B";const minutesAgo = (minutes: number) => Date.now() - minutes * 60 * 1000;const hoursAgo = (hours: number) => minutesAgo(hours * 60);const daysAgo = (days: number) => hoursAgo(days * 24);+const sampleFeedPhotoAspectRatio = 900 / 680;const sampleFeedItems = [{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-4.jpg",imageUrl: "/images/sample-feed-1.jpg",name: "Aparna Bhatnagar",timestampMs: minutesAgo(22),},{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-3.jpg",imageUrl: "/images/sample-feed-2.jpg",name: "Mira Sen",timestampMs: hoursAgo(3),},{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-5.jpg",imageUrl: "/images/sample-feed-3.jpg",name: "Nikhil Rao",timestampMs: daysAgo(1),},{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-6.jpg",imageUrl: "/images/sample-feed-4.jpg",name: "Riya Kapoor",timestampMs: daysAgo(2),},{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-4.jpg",imageUrl: "/images/sample-feed-5.jpg",name: "Aparna Bhatnagar",timestampMs: daysAgo(4),},{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-3.jpg",imageUrl: "/images/sample-feed-6.jpg",name: "Mira Sen",timestampMs: daysAgo(8),},{+ aspectRatio: sampleFeedPhotoAspectRatio,avatarUrl: "/images/sample-feed-5.jpg",imageUrl: "/images/sample-feed-2.jpg",name: "Nikhil Rao",@@ -65,41 +78,14 @@ interface HomeScreenProps {}interface FeedItemProps {+ aspectRatio: number;avatarUrl: string;imageUrl: string;name: string;+ onOpenPhoto?: (photo: SocialViewerPhoto) => void;timestampMs: number;}-const firstNameFrom = (name: string) => name.trim().split(/\s+/)[0] || name;--const formatFeedDate = (timestampMs: number): string => {- const now = Date.now();- const diff = now - timestampMs;- const minutes = Math.floor(diff / 60000);- if (minutes < 1) return "just now";- if (minutes < 60) return `${minutes}m ago`;- const hours = Math.floor(minutes / 60);- if (hours < 24) return `${hours}h ago`;- const days = Math.floor(hours / 24);- if (days < 7) return `${days}d ago`;-- const date = new Date(timestampMs);- const locale =- typeof navigator == "undefined" ? "en-US" : navigator.language;- if (date.getFullYear() == new Date(now).getFullYear()) {- return date.toLocaleDateString(locale, {- month: "short",- day: "numeric",- });- }- return date.toLocaleDateString(locale, {- month: "short",- day: "numeric",- year: "numeric",- });-};-const PlusIcon: React.FC = () => (<Boxcomponent="svg"@@ -119,13 +105,15 @@ const PlusIcon: React.FC = () => ();const FeedItem: React.FC<FeedItemProps> = ({+ aspectRatio,avatarUrl,imageUrl,name,+ onOpenPhoto,timestampMs,}) => {const firstName = firstNameFrom(name);- const dateLabel = formatFeedDate(timestampMs);+ const dateLabel = formatSocialDate(timestampMs);return (<Box@@ -217,14 +205,34 @@ const FeedItem: React.FC<FeedItemProps> = ({</Box></Box><Box+ component="button"+ type="button"+ aria-label={`Open ${name} photo`}+ onClick={() =>+ onOpenPhoto?.({+ alt: `${name} post`,+ avatarUrl,+ imageUrl,+ name,+ timestampMs,+ })+ }sx={{- aspectRatio: "4 / 5",+ appearance: "none",+ aspectRatio,bgcolor: paleGreen,+ border: 0,borderRadius: "20px",display: "block",+ cursor: onOpenPhoto ? "pointer" : "default",mx: "16px",overflow: "hidden",+ p: 0,width: "calc(100% - 32px)",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },}}><Box@@ -248,6 +256,8 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({onOpenProfile,profile,}) => {+ const [selectedPhoto, setSelectedPhoto] =+ useState<SocialViewerPhoto | null>(null);const initialsSource = profile.fullName.trim() || profile.username.trim();const initials = initialsSource.split(/\s+/)@@ -382,13 +392,21 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({{sampleFeedItems.map((item) => (<FeedItemkey={`${item.name}-${item.imageUrl}`}+ aspectRatio={item.aspectRatio}avatarUrl={item.avatarUrl}imageUrl={item.imageUrl}name={item.name}+ onOpenPhoto={setSelectedPhoto}timestampMs={item.timestampMs}/>))}</Box>+ {selectedPhoto && (+ <SocialFileViewer+ photo={selectedPhoto}+ onClose={() => setSelectedPhoto(null)}+ />+ )}</Box></Box>);diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsxindex cc7ee431c9..fb52e86072 100644--- a/web/apps/social/src/screens/ProfileScreen.tsx+++ b/web/apps/social/src/screens/ProfileScreen.tsx@@ -5,11 +5,16 @@ import {} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box, Menu, MenuItem } from "@mui/material";+import {+ SocialFileViewer,+ type SocialViewerPhoto,+} from "components/SocialFileViewer";import { EnteLogo } from "ente-base/components/EnteLogo";import React, { useState } from "react";import type { SetupProfile } from "screens/SetupProfileScreen";import { LinkIcon, ShareIcon } from "screens/ShareProfileLinkScreen";import { profileLinkForUsername } from "utils/profileLink";+import { initialsFor } from "utils/socialDisplay";export const profileBackground = "#FFFFFF";@@ -52,6 +57,15 @@ const samplePostDateLabels = [];const samplePostPhotoCounts = [4, 2, 1, 6, 10, 3, 8, 5, 7, 9];+const minutesAgo = (minutes: number) => Date.now() - minutes * 60 * 1000;+const hoursAgo = (hours: number) => minutesAgo(hours * 60);+const daysAgo = (days: number) => hoursAgo(days * 24);++const samplePostTimestampAt = (groupIndex: number, itemIndex: number) => {+ if (groupIndex == 0) return minutesAgo(18 + itemIndex * 12);+ if (groupIndex == 1) return hoursAgo(26 + itemIndex * 3);+ return daysAgo(groupIndex + 1) - itemIndex * 20 * 60 * 1000;+};const samplePhotoUrlAt = (index: number): string =>samplePhotoUrls[index % samplePhotoUrls.length] ?? samplePhotoUrls[0];@@ -66,6 +80,7 @@ const samplePostGroups = samplePostDateLabels.map((label, groupIndex) => ({(_, itemIndex) => ({imageUrl: samplePhotoUrlAt(groupIndex + itemIndex),aspectRatio: samplePhotoAspectRatioAt(groupIndex + itemIndex),+ timestampMs: samplePostTimestampAt(groupIndex, itemIndex),}),),}));@@ -154,17 +169,15 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({}) => {const [profileActionsAnchor, setProfileActionsAnchor] =useState<HTMLElement | null>(null);+ const [selectedPhoto, setSelectedPhoto] =+ useState<SocialViewerPhoto | null>(null);const isPublicProfile = headerVariant == "public";const isOwnerProfile = headerVariant == "owner";const isFriendProfile = headerVariant == "friend";const displayName = profile.fullName.trim() || profile.username.trim();const profileLink = profileLinkForUsername(profile.username.trim());const initialsSource = displayName || profile.username.trim();- const initials = initialsSource- .split(/\s+/)- .slice(0, 2)- .map((part) => part[0]?.toUpperCase())- .join("");+ const initials = initialsFor(initialsSource);const postsSharedCount = samplePostGroups.reduce((count, group) => count + group.items.length,0,@@ -801,13 +814,41 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({{row.items.map(({ item, index }) => (<Box+ component="button"+ type="button"+ aria-label={`Open ${displayName} post ${+ index + 1+ }`}+ onClick={() =>+ setSelectedPhoto({+ alt: `${displayName} post ${+ index + 1+ }`,+ avatarUrl:+ profile.avatarUrl,+ imageUrl:+ item.imageUrl,+ name: displayName,+ timestampMs:+ item.timestampMs,+ })+ }key={`${group.label}-${item.imageUrl}-${index}`}sx={{+ appearance: "none",bgcolor: paleGreen,+ border: 0,+ cursor: "pointer",display: "block",flex: `${item.aspectRatio} 1 0`,minWidth: 0,overflow: "hidden",+ p: 0,+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset:+ -2,+ },}}><Box@@ -837,6 +878,12 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({</Box>))}</Box>+ {selectedPhoto && (+ <SocialFileViewer+ photo={selectedPhoto}+ onClose={() => setSelectedPhoto(null)}+ />+ )}</Box></Box>);diff --git a/web/apps/social/src/styles/globals.css b/web/apps/social/src/styles/globals.cssindex 7cc1139bda..c98b76982a 100644--- a/web/apps/social/src/styles/globals.css+++ b/web/apps/social/src/styles/globals.css@@ -11,3 +11,8 @@background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAsTAAALEwEAmpwYAAABaWlDQ1BEaXNwbGF5IFAzAAB4nHWQvUvDUBTFT6tS0DqIDh0cMolD1NIKdnFoKxRFMFQFq1OafgltfCQpUnETVyn4H1jBWXCwiFRwcXAQRAcR3Zw6KbhoeN6XVNoi3sfl/Ticc7lcwBtQGSv2AijplpFMxKS11Lrke4OHnlOqZrKooiwK/v276/PR9d5PiFlNu3YQ2U9cl84ul3aeAlN//V3Vn8maGv3f1EGNGRbgkYmVbYsJ3iUeMWgp4qrgvMvHgtMunzuelWSc+JZY0gpqhrhJLKc79HwHl4plrbWD2N6f1VeXxRzqUcxhEyYYilBRgQQF4X/8044/ji1yV2BQLo8CLMpESRETssTz0KFhEjJxCEHqkLhz634PrfvJbW3vFZhtcM4v2tpCAzidoZPV29p4BBgaAG7qTDVUR+qh9uZywPsJMJgChu8os2HmwiF3e38M6Hvh/GMM8B0CdpXzryPO7RqFn4Er/QcXKWq8MSlPPgAAABBJREFUeAEBBQD6/wAIwiX/A7QB7/maltEAAAAASUVORK5CYII=")repeat;}++.pswp-social-viewer {+ --pswp-root-z-index: 0;+ --pswp-bg: #000000;+}diff --git a/web/apps/social/src/utils/socialDisplay.ts b/web/apps/social/src/utils/socialDisplay.tsnew file mode 100644index 0000000000..b561c53463--- /dev/null+++ b/web/apps/social/src/utils/socialDisplay.ts@@ -0,0 +1,37 @@+export const firstNameFrom = (name: string) =>+ name.trim().split(/\s+/)[0] || name;++export const initialsFor = (name: string) =>+ name+ .trim()+ .split(/\s+/)+ .slice(0, 2)+ .map((part) => part[0]?.toUpperCase())+ .join("");++export const formatSocialDate = (timestampMs: number): string => {+ const now = Date.now();+ const diff = now - timestampMs;+ const minutes = Math.floor(diff / 60000);+ if (minutes < 1) return "just now";+ if (minutes < 60) return `${minutes}m ago`;+ const hours = Math.floor(minutes / 60);+ if (hours < 24) return `${hours}h ago`;+ const days = Math.floor(hours / 24);+ if (days < 7) return `${days}d ago`;++ const date = new Date(timestampMs);+ const locale =+ typeof navigator == "undefined" ? "en-US" : navigator.language;+ if (date.getFullYear() == new Date(now).getFullYear()) {+ return date.toLocaleDateString(locale, {+ month: "short",+ day: "numeric",+ });+ }+ return date.toLocaleDateString(locale, {+ month: "short",+ day: "numeric",+ year: "numeric",+ });+};