From 27b844d1bbf7404e8f964f3f25d8e61fa8778d77 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 18 Jun 2024 11:18:42 -0500 Subject: [PATCH] Tweaks --- src/components/NewskieDialog.tsx | 67 +++++++++++++++++++++++++++ src/screens/Profile/Header/Handle.tsx | 6 +-- 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 src/components/NewskieDialog.tsx diff --git a/src/components/NewskieDialog.tsx b/src/components/NewskieDialog.tsx new file mode 100644 index 0000000000..90a3acb66c --- /dev/null +++ b/src/components/NewskieDialog.tsx @@ -0,0 +1,67 @@ +import React from 'react' +import {View} from 'react-native' +import {AppBskyActorDefs} from '@atproto/api' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' +import {differenceInSeconds} from 'date-fns' + +import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo' +import {HITSLOP_10} from 'lib/constants' +import {isNative} from 'platform/detection' +import {atoms as a} from '#/alf' +import {Button} from '#/components/Button' +import * as Dialog from '#/components/Dialog' +import {useDialogControl} from '#/components/Dialog' +import {Newskie} from '#/components/icons/Newskie' +import {Text} from '#/components/Typography' + +export function NewskieDialog({ + profile, +}: { + profile: AppBskyActorDefs.ProfileViewDetailed +}) { + const {_} = useLingui() + const control = useDialogControl() + const profileName = profile.displayName || `@${profile.handle}` + const timeAgo = useGetTimeAgo() + const daysOld = React.useMemo(() => { + if (!profile.createdAt) return Infinity + return ( + differenceInSeconds(new Date(), new Date(profile.createdAt as string)) / + 86400 + ) + }, [profile.createdAt]) + + if (!profile.createdAt) return null + if (daysOld > 7) return null + + return ( + <> + + + + + + + + Say hello! + + + + {profileName} recently joined Bluesky{' '} + {timeAgo(profile.createdAt as string, {format: 'long'})} ago + + + + + + + ) +} diff --git a/src/screens/Profile/Header/Handle.tsx b/src/screens/Profile/Header/Handle.tsx index 7a4485e1c4..4f438a2868 100644 --- a/src/screens/Profile/Header/Handle.tsx +++ b/src/screens/Profile/Header/Handle.tsx @@ -7,7 +7,7 @@ import {Shadow} from '#/state/cache/types' import {isInvalidHandle} from 'lib/strings/handles' import {isAndroid} from 'platform/detection' import {atoms as a, useTheme, web} from '#/alf' -import {NewskieDialog} from '#/components/StarterPack/NewskieDialog' +import {NewskieDialog} from '#/components/NewskieDialog' import {Text} from '#/components/Typography' export function ProfileHeaderHandle({ @@ -22,9 +22,7 @@ export function ProfileHeaderHandle({ - - - + {profile.viewer?.followedBy && !blockHide ? (