Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Misc. fixes

Tim Wilsona5bcdd437647
diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsx
index 7d485739d4..21c672b64f 100644
--- a/apps/web/ui/links/link-title-column.tsx
+++ b/apps/web/ui/links/link-title-column.tsx
@@ -381,7 +381,11 @@ const Details = memo(
displayProperties.includes("createdAt") && "sm:block",
)}
>
- <TimestampTooltip timestamp={createdAt} delayDuration={150}>
+ <TimestampTooltip
+ timestamp={createdAt}
+ rows={["local"]}
+ delayDuration={150}
+ >
<span className="text-neutral-400">{timeAgo(createdAt)}</span>
</TimestampTooltip>
</div>
diff --git a/packages/ui/src/timestamp-tooltip.tsx b/packages/ui/src/timestamp-tooltip.tsx
index c2b6e4fca4..ba3f67ecb4 100644
--- a/packages/ui/src/timestamp-tooltip.tsx
+++ b/packages/ui/src/timestamp-tooltip.tsx
@@ -25,7 +25,17 @@ function getLocalTimeZone(): string {
return "Local";
}
-export function TimestampTooltip({
+export function TimestampTooltip(props: TimestampTooltipProps) {
+ if (
+ !props.timestamp ||
+ new Date(props.timestamp).toString() === "Invalid Date"
+ )
+ return props.children;
+
+ return <TimestampTooltipContent {...props} />;
+}
+
+function TimestampTooltipContent({
timestamp,
children,
rows = ["local", "utc"],
@@ -33,12 +43,11 @@ export function TimestampTooltip({
className,
...tooltipProps
}: TimestampTooltipProps) {
- if (!timestamp) return children;
+ if (!timestamp)
+ throw new Error("Falsy timestamp not permitted in TimestampTooltipContent");
const date = new Date(timestamp);
- if (date.toString() === "Invalid Date") return children;
-
const commonFormat: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "short",
@@ -126,9 +135,9 @@ export function TimestampTooltip({
)}
onClick={
interactive
- ? () => {
+ ? async () => {
try {
- navigator.clipboard.writeText(row.value);
+ await navigator.clipboard.writeText(row.value);
toast.success("Copied to clipboard");
} catch (e) {
toast.error("Failed to copy to clipboard");