From 32ab893aac28451a93e35d1264465b973e6685bb Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 18 Jun 2024 12:11:29 -0500 Subject: [PATCH] Simplify logic --- src/components/NewskieDialog.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/NewskieDialog.tsx b/src/components/NewskieDialog.tsx index f954301cc0..68a067280f 100644 --- a/src/components/NewskieDialog.tsx +++ b/src/components/NewskieDialog.tsx @@ -23,15 +23,15 @@ export function NewskieDialog({ const control = useDialogControl() const profileName = profile.displayName || `@${profile.handle}` const timeAgo = useGetTimeAgo() + const createdAt = profile.createdAt as string | undefined const daysOld = React.useMemo(() => { - if (!profile.createdAt) return Infinity + if (!createdAt) return Infinity return ( - differenceInSeconds(new Date(), new Date(profile.createdAt as string)) / - 86400 + differenceInSeconds(new Date(), new Date(createdAt as string)) / 86400 ) - }, [profile.createdAt]) + }, [createdAt]) - if (daysOld > 7) return null + if (!createdAt || daysOld > 7) return null return ( @@ -64,7 +64,7 @@ export function NewskieDialog({ {profileName} joined Bluesky{' '} - {timeAgo(profile.createdAt as string, {format: 'long'})} ago + {timeAgo(createdAt, {format: 'long'})} ago