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:
parent
fb76265fcc
commit
983d85384b
4 changed files with 15 additions and 19 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue