Simplify logic
This commit is contained in:
@@ -23,15 +23,15 @@ export function NewskieDialog({
|
|||||||
const control = useDialogControl()
|
const control = useDialogControl()
|
||||||
const profileName = profile.displayName || `@${profile.handle}`
|
const profileName = profile.displayName || `@${profile.handle}`
|
||||||
const timeAgo = useGetTimeAgo()
|
const timeAgo = useGetTimeAgo()
|
||||||
|
const createdAt = profile.createdAt as string | undefined
|
||||||
const daysOld = React.useMemo(() => {
|
const daysOld = React.useMemo(() => {
|
||||||
if (!profile.createdAt) return Infinity
|
if (!createdAt) return Infinity
|
||||||
return (
|
return (
|
||||||
differenceInSeconds(new Date(), new Date(profile.createdAt as string)) /
|
differenceInSeconds(new Date(), new Date(createdAt as string)) / 86400
|
||||||
86400
|
|
||||||
)
|
)
|
||||||
}, [profile.createdAt])
|
}, [createdAt])
|
||||||
|
|
||||||
if (daysOld > 7) return null
|
if (!createdAt || daysOld > 7) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.pr_2xs]}>
|
<View style={[a.pr_2xs]}>
|
||||||
@@ -64,7 +64,7 @@ export function NewskieDialog({
|
|||||||
<Text style={[a.text_md]}>
|
<Text style={[a.text_md]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
{profileName} joined Bluesky{' '}
|
{profileName} joined Bluesky{' '}
|
||||||
{timeAgo(profile.createdAt as string, {format: 'long'})} ago
|
{timeAgo(createdAt, {format: 'long'})} ago
|
||||||
</Trans>
|
</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user