fix: stale time ago in streams list

This commit is contained in:
talksik
2026-03-25 15:53:35 -07:00
parent d817e637c0
commit 0ab2ec2bb8
2 changed files with 24 additions and 2 deletions
+22
View File
@@ -0,0 +1,22 @@
import { useEffect, useState } from "react";
import { formatDistanceToNow } from "@/lib/time-utils";
const TICK_MS = 30_000;
interface RelativeTimestampProps {
date: Date;
}
/**
* Displays a relative timestamp (e.g. "5m ago") that auto-refreshes every 30s.
*/
export function RelativeTimestamp({ date }: RelativeTimestampProps) {
const [, setTick] = useState(0);
useEffect(() => {
const id = setInterval(() => setTick((t) => t + 1), TICK_MS);
return () => clearInterval(id);
}, []);
return <>{formatDistanceToNow(date.toISOString())}</>;
}
@@ -21,7 +21,7 @@ import {
type ParticlePath,
} from "@/lib/particle-path";
import { getInitials } from "@/lib/utils";
import { formatDistanceToNow } from "@/lib/time-utils";
import { RelativeTimestamp } from "@/components/relative-timestamp";
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Separator } from "@/components/ui/separator";
import { Progress } from "@/components/ui/progress";
@@ -205,7 +205,7 @@ function StreamRow({
isUnseen ? "text-primary" : "text-muted-foreground",
)}
>
{formatDistanceToNow(latestChild.created_at.toISOString())}
<RelativeTimestamp date={latestChild.created_at} />
</Small>
)}
</div>