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
34 changes: 34 additions & 0 deletions apps/code/src/renderer/components/ui/RelativeTimestamp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Tooltip } from "@components/ui/Tooltip";
import { Text } from "@radix-ui/themes";
import { formatRelativeTimeLong } from "@utils/time";

interface RelativeTimestampProps {
timestamp: string | number | Date | null | undefined;
className?: string;
}

export function RelativeTimestamp({
timestamp,
className,
}: RelativeTimestampProps) {
const date =
timestamp instanceof Date
? timestamp
: timestamp !== null && timestamp !== undefined
? new Date(timestamp)
: null;

if (date === null || Number.isNaN(date.getTime())) {
return null;
}

return (
<Tooltip content={date.toLocaleString()}>
<Text
className={`shrink-0 text-(--gray-10) text-[11px] ${className ?? ""}`}
Comment thread
oliverb123 marked this conversation as resolved.
>
{formatRelativeTimeLong(date.getTime())}
Comment thread
oliverb123 marked this conversation as resolved.
</Text>
</Tooltip>
);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RelativeTimestamp } from "@components/ui/RelativeTimestamp";
import { useAuthStateValue } from "@features/auth/hooks/authQueries";
import { MarkdownRenderer } from "@features/editor/components/MarkdownRenderer";
import { SOURCE_PRODUCT_META } from "@features/inbox/components/utils/source-product-icons";
Expand Down Expand Up @@ -261,6 +262,7 @@ function SignalCardHeader({
{signalCardSourceLine(signal)}
</Text>
<span className="flex-1" />
<RelativeTimestamp timestamp={signal.timestamp} />
{verified === true && <VerificationBadge />}
</Flex>
);
Expand Down Expand Up @@ -769,9 +771,6 @@ function GenericSignalCard({
<Box className="min-w-0 overflow-hidden rounded-lg border border-gray-6 bg-gray-1 p-3">
<SignalCardHeader signal={signal} verified={verified} />
<CollapsibleBody body={signal.content} />
<Text className="mt-2 block text-(--gray-10) text-[11px]">
{new Date(signal.timestamp).toLocaleString()}
</Text>
<CodePathsCollapsible paths={codePaths ?? []} />
<DataQueriedCollapsible text={dataQueried ?? ""} />
</Box>
Expand Down
Loading