Force callers of getTimeAgo to pass in the value for "now" (#4560)

* Remove icky hook for now

* Force callers of getTimeAgo to pass in the 'now' value

* Update usage in Newskie dialog
This commit is contained in:
Eric Bailey 2024-06-18 13:50:07 -05:00 committed by GitHub
parent fb76265fcc
commit 983d85384b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 19 deletions

View file

@ -30,12 +30,13 @@ export function NewskieDialog({
const moderation = moderateProfile(profile, moderationOpts)
return sanitizeDisplayName(name, moderation.ui('displayName'))
}, [moderationOpts, profile])
const [now] = React.useState(Date.now())
const timeAgo = useGetTimeAgo()
const createdAt = profile.createdAt as string | undefined
const daysOld = React.useMemo(() => {
if (!createdAt) return Infinity
return differenceInSeconds(new Date(), new Date(createdAt)) / 86400
}, [createdAt])
return differenceInSeconds(now, new Date(createdAt)) / 86400
}, [createdAt, now])
if (!createdAt || daysOld > 7) return null
@ -70,7 +71,7 @@ export function NewskieDialog({
<Text style={[a.text_md]}>
<Trans>
{profileName} joined Bluesky{' '}
{timeAgo(createdAt, {format: 'long'})} ago
{timeAgo(createdAt, now, {format: 'long'})} ago
</Trans>
</Text>
</View>