diff --git a/src/pages/secondary/ProfilePage/Followings.tsx b/src/pages/secondary/ProfilePage/Followings.tsx new file mode 100644 index 00000000..07dca48b --- /dev/null +++ b/src/pages/secondary/ProfilePage/Followings.tsx @@ -0,0 +1,30 @@ +import { useFetchFollowings } from '@/hooks' +import { toFollowingList } from '@/lib/link' +import { SecondaryPageLink } from '@/PageManager' +import { useFollowList } from '@/providers/FollowListProvider' +import { useNostr } from '@/providers/NostrProvider' +import { Loader } from 'lucide-react' +import { useTranslation } from 'react-i18next' + +export default function Followings({ pubkey }: { pubkey: string }) { + const { t } = useTranslation() + const { pubkey: accountPubkey } = useNostr() + const { followings: selfFollowings } = useFollowList() + const { followings, isFetching } = useFetchFollowings(pubkey) + + return ( + + {accountPubkey === pubkey ? ( + selfFollowings.length + ) : isFetching ? ( + + ) : ( + followings.length + )} +
{t('Following')}
+
+ ) +} diff --git a/src/pages/secondary/ProfilePage/Relays.tsx b/src/pages/secondary/ProfilePage/Relays.tsx new file mode 100644 index 00000000..d4772a4d --- /dev/null +++ b/src/pages/secondary/ProfilePage/Relays.tsx @@ -0,0 +1,22 @@ +import { useFetchRelayList } from '@/hooks' +import { toOthersRelaySettings, toRelaySettings } from '@/lib/link' +import { SecondaryPageLink } from '@/PageManager' +import { useNostr } from '@/providers/NostrProvider' +import { Loader } from 'lucide-react' +import { useTranslation } from 'react-i18next' + +export default function Relays({ pubkey }: { pubkey: string }) { + const { t } = useTranslation() + const { pubkey: accountPubkey } = useNostr() + const { relayList, isFetching } = useFetchRelayList(pubkey) + + return ( + + {isFetching ? : relayList.originalRelays.length} +
{t('Relays')}
+
+ ) +} diff --git a/src/pages/secondary/ProfilePage/index.tsx b/src/pages/secondary/ProfilePage/index.tsx index c25660fd..bf9db6cd 100644 --- a/src/pages/secondary/ProfilePage/index.tsx +++ b/src/pages/secondary/ProfilePage/index.tsx @@ -12,23 +12,18 @@ import { Skeleton } from '@/components/ui/skeleton' import { useFetchFollowings, useFetchProfile } from '@/hooks' import { useFetchRelayList } from '@/hooks/useFetchRelayList' import SecondaryPageLayout from '@/layouts/SecondaryPageLayout' -import { - toFollowingList, - toMuteList, - toOthersRelaySettings, - toProfileEditor, - toRelaySettings -} from '@/lib/link' +import { toMuteList, toProfileEditor } from '@/lib/link' import { generateImageByPubkey } from '@/lib/pubkey' import { SecondaryPageLink, useSecondaryPage } from '@/PageManager' import { useFeed } from '@/providers/FeedProvider' -import { useFollowList } from '@/providers/FollowListProvider' import { useMuteList } from '@/providers/MuteListProvider' import { useNostr } from '@/providers/NostrProvider' import { Link } from 'lucide-react' import { forwardRef, useMemo } from 'react' import { useTranslation } from 'react-i18next' import NotFoundPage from '../NotFoundPage' +import Followings from './Followings' +import Relays from './Relays' const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref) => { const { t } = useTranslation() @@ -44,7 +39,6 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, [relayList, currentRelayUrls] ) const { pubkey: accountPubkey } = useNostr() - const { followings: selfFollowings } = useFollowList() const { mutePubkeys } = useMuteList() const { followings } = useFetchFollowings(profile?.pubkey) const isFollowingYou = useMemo(() => { @@ -127,20 +121,8 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, )}
- - {isSelf ? selfFollowings.length : followings.length} -
{t('Following')}
-
- - {relayList.originalRelays.length} -
{t('Relays')}
-
+ + {isSelf && ( {mutePubkeys.length}