6 changed files with 174 additions and 26 deletions
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
import { useFetchFollowings } from '@/hooks' |
||||
import { toFollowingList } from '@/lib/link' |
||||
import { useSmartProfileNavigation } 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 SmartFollowings({ pubkey }: { pubkey: string }) { |
||||
const { t } = useTranslation() |
||||
const { pubkey: accountPubkey } = useNostr() |
||||
const { followings: selfFollowings } = useFollowList() |
||||
const { followings, isFetching } = useFetchFollowings(pubkey) |
||||
const { navigateToProfile } = useSmartProfileNavigation() |
||||
|
||||
const handleClick = () => { |
||||
navigateToProfile(toFollowingList(pubkey)) |
||||
} |
||||
|
||||
return ( |
||||
<span |
||||
className="flex gap-1 hover:underline w-fit items-center cursor-pointer" |
||||
onClick={handleClick} |
||||
> |
||||
{accountPubkey === pubkey ? ( |
||||
selfFollowings.length |
||||
) : isFetching ? ( |
||||
<Loader className="animate-spin size-4" /> |
||||
) : ( |
||||
followings.length |
||||
)} |
||||
<div className="text-muted-foreground">{t('Following')}</div> |
||||
</span> |
||||
) |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
import { toMuteList } from '@/lib/link' |
||||
import { useSmartSettingsNavigation } from '@/PageManager' |
||||
import { useMuteList } from '@/providers/MuteListProvider' |
||||
import { useTranslation } from 'react-i18next' |
||||
|
||||
export default function SmartMuteLink() { |
||||
const { t } = useTranslation() |
||||
const { mutePubkeySet } = useMuteList() |
||||
const { navigateToSettings } = useSmartSettingsNavigation() |
||||
|
||||
const handleClick = () => { |
||||
navigateToSettings(toMuteList()) |
||||
} |
||||
|
||||
return ( |
||||
<span |
||||
className="flex gap-1 hover:underline w-fit cursor-pointer" |
||||
onClick={handleClick} |
||||
> |
||||
{mutePubkeySet.size} |
||||
<div className="text-muted-foreground">{t('Muted')}</div> |
||||
</span> |
||||
) |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
import { useFetchRelayList } from '@/hooks' |
||||
import { toOthersRelaySettings, toRelaySettings } from '@/lib/link' |
||||
import { useSmartSettingsNavigation } from '@/PageManager' |
||||
import { useNostr } from '@/providers/NostrProvider' |
||||
import { Loader } from 'lucide-react' |
||||
import { useTranslation } from 'react-i18next' |
||||
|
||||
export default function SmartRelays({ pubkey }: { pubkey: string }) { |
||||
const { t } = useTranslation() |
||||
const { pubkey: accountPubkey } = useNostr() |
||||
const { relayList, isFetching } = useFetchRelayList(pubkey) |
||||
const { navigateToSettings } = useSmartSettingsNavigation() |
||||
|
||||
const handleClick = () => { |
||||
const url = accountPubkey === pubkey ? toRelaySettings('mailbox') : toOthersRelaySettings(pubkey) |
||||
navigateToSettings(url) |
||||
} |
||||
|
||||
return ( |
||||
<span |
||||
className="flex gap-1 hover:underline w-fit items-center cursor-pointer" |
||||
onClick={handleClick} |
||||
> |
||||
{isFetching ? <Loader className="animate-spin size-4" /> : relayList.originalRelays.length} |
||||
<div className="text-muted-foreground">{t('Relays')}</div> |
||||
</span> |
||||
) |
||||
} |
||||
Loading…
Reference in new issue