feat: 💨

This commit is contained in:
codytseng
2025-09-06 16:44:50 +08:00
parent fc138609a1
commit 647f9062f8
9 changed files with 64 additions and 92 deletions

View File

@@ -82,7 +82,6 @@ export default function PostContent({
relays: [] relays: []
} }
) )
setSpecifiedRelayUrls(cachedSettings.specifiedRelayUrls)
setAddClientTag(cachedSettings.addClientTag ?? false) setAddClientTag(cachedSettings.addClientTag ?? false)
} }
return return
@@ -93,7 +92,6 @@ export default function PostContent({
isNsfw, isNsfw,
isPoll, isPoll,
pollCreateData, pollCreateData,
specifiedRelayUrls,
addClientTag addClientTag
} }
) )

View File

@@ -8,12 +8,6 @@ export default function RelayBadges({ relayInfo }: { relayInfo: TRelayInfo }) {
const badges = useMemo(() => { const badges = useMemo(() => {
const b: string[] = [] const b: string[] = []
if (relayInfo.limitation?.auth_required) {
b.push('Auth')
}
if (relayInfo.supported_nips?.includes(50)) {
b.push('Search')
}
if (relayInfo.limitation?.payment_required) { if (relayInfo.limitation?.payment_required) {
b.push('Payment') b.push('Payment')
} }
@@ -26,12 +20,6 @@ export default function RelayBadges({ relayInfo }: { relayInfo: TRelayInfo }) {
return ( return (
<div className="flex gap-2"> <div className="flex gap-2">
{badges.includes('Auth') && (
<Badge className="bg-green-400 hover:bg-green-400/80">{t('relayInfoBadgeAuth')}</Badge>
)}
{badges.includes('Search') && (
<Badge className="bg-pink-400 hover:bg-pink-400/80">{t('relayInfoBadgeSearch')}</Badge>
)}
{badges.includes('Payment') && ( {badges.includes('Payment') && (
<Badge className="bg-orange-400 hover:bg-orange-400/80">{t('relayInfoBadgePayment')}</Badge> <Badge className="bg-orange-400 hover:bg-orange-400/80">{t('relayInfoBadgePayment')}</Badge>
)} )}

View File

@@ -3,12 +3,14 @@ import { Button } from '@/components/ui/button'
import { useFetchRelayInfo } from '@/hooks' import { useFetchRelayInfo } from '@/hooks'
import { normalizeHttpUrl } from '@/lib/url' import { normalizeHttpUrl } from '@/lib/url'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { GitBranch, Mail, SquareCode } from 'lucide-react' import { Check, Copy, GitBranch, Link, Mail, SquareCode } from 'lucide-react'
import { useState } from 'react' import { useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import PostEditor from '../PostEditor' import PostEditor from '../PostEditor'
import RelayBadges from '../RelayBadges' import RelayBadges from '../RelayBadges'
import RelayIcon from '../RelayIcon' import RelayIcon from '../RelayIcon'
import SaveRelayDropdownMenu from '../SaveRelayDropdownMenu'
import UserAvatar from '../UserAvatar' import UserAvatar from '../UserAvatar'
import Username from '../Username' import Username from '../Username'
@@ -24,11 +26,14 @@ export default function RelayInfo({ url, className }: { url: string; className?:
return ( return (
<div className={cn('px-4 space-y-4 mb-2', className)}> <div className={cn('px-4 space-y-4 mb-2', className)}>
<div className="space-y-2"> <div className="space-y-2">
<div className="flex gap-2 items-center"> <div className="flex items-center gap-2 justify-between">
<RelayIcon url={url} className="w-8 h-8" /> <div className="flex gap-2 items-center">
<div className="text-2xl font-semibold truncate select-text"> <RelayIcon url={url} className="w-8 h-8" />
{relayInfo.name || relayInfo.shortUrl} <div className="text-2xl font-semibold truncate select-text">
{relayInfo.name || relayInfo.shortUrl}
</div>
</div> </div>
<RelayControls url={relayInfo.url} />
</div> </div>
<RelayBadges relayInfo={relayInfo} /> <RelayBadges relayInfo={relayInfo} />
{!!relayInfo.tags?.length && ( {!!relayInfo.tags?.length && (
@@ -107,3 +112,33 @@ function formatSoftware(software: string) {
const parts = software.split('/') const parts = software.split('/')
return parts[parts.length - 1] return parts[parts.length - 1]
} }
function RelayControls({ url }: { url: string }) {
const [copiedUrl, setCopiedUrl] = useState(false)
const [copiedShareableUrl, setCopiedShareableUrl] = useState(false)
const handleCopyUrl = () => {
navigator.clipboard.writeText(url)
setCopiedUrl(true)
setTimeout(() => setCopiedUrl(false), 2000)
}
const handleCopyShareableUrl = () => {
navigator.clipboard.writeText(`https://jumble.social/?r=${url}`)
setCopiedShareableUrl(true)
toast.success('Shareable URL copied to clipboard')
setTimeout(() => setCopiedShareableUrl(false), 2000)
}
return (
<div className="flex items-center gap-1">
<Button variant="ghost" size="titlebar-icon" onClick={handleCopyShareableUrl}>
{copiedShareableUrl ? <Check /> : <Link />}
</Button>
<Button variant="ghost" size="titlebar-icon" onClick={handleCopyUrl}>
{copiedUrl ? <Check /> : <Copy />}
</Button>
<SaveRelayDropdownMenu urls={[url]} atTitlebar />
</div>
)
}

View File

@@ -1,35 +0,0 @@
import { Button } from '@/components/ui/button'
import { Check, Copy, Link } from 'lucide-react'
import { useState } from 'react'
import { toast } from 'sonner'
import SaveRelayDropdownMenu from '../SaveRelayDropdownMenu'
export default function RelayPageControls({ url }: { url: string }) {
const [copiedUrl, setCopiedUrl] = useState(false)
const [copiedShareableUrl, setCopiedShareableUrl] = useState(false)
const handleCopyUrl = () => {
navigator.clipboard.writeText(url)
setCopiedUrl(true)
setTimeout(() => setCopiedUrl(false), 2000)
}
const handleCopyShareableUrl = () => {
navigator.clipboard.writeText(`https://jumble.social/?r=${url}`)
setCopiedShareableUrl(true)
toast.success('Shareable URL copied to clipboard')
setTimeout(() => setCopiedShareableUrl(false), 2000)
}
return (
<>
<Button variant="ghost" size="titlebar-icon" onClick={handleCopyShareableUrl}>
{copiedShareableUrl ? <Check /> : <Link />}
</Button>
<Button variant="ghost" size="titlebar-icon" onClick={handleCopyUrl}>
{copiedUrl ? <Check /> : <Copy />}
</Button>
<SaveRelayDropdownMenu urls={[url]} atTitlebar />
</>
)
}

View File

@@ -1,7 +1,4 @@
import Nip05 from '@/components/Nip05'
import SearchInput from '@/components/SearchInput' import SearchInput from '@/components/SearchInput'
import UserAvatar from '@/components/UserAvatar'
import Username from '@/components/Username'
import { useSearchProfiles } from '@/hooks' import { useSearchProfiles } from '@/hooks'
import { toNote } from '@/lib/link' import { toNote } from '@/lib/link'
import { randomString } from '@/lib/random' import { randomString } from '@/lib/random'
@@ -23,7 +20,7 @@ import {
useState useState
} from 'react' } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { UserItemSkeleton } from '../UserItem' import UserItem, { UserItemSkeleton } from '../UserItem'
const SearchBar = forwardRef< const SearchBar = forwardRef<
TSearchBarRef, TSearchBarRef,
@@ -154,7 +151,11 @@ const SearchBar = forwardRef<
} }
/> />
))} ))}
{isFetchingProfiles && profiles.length < 5 && <UserItemSkeleton hideFollowButton />} {isFetchingProfiles && profiles.length < 5 && (
<div className="px-2">
<UserItemSkeleton hideFollowButton />
</div>
)}
{profiles.length >= 5 && ( {profiles.length >= 5 && (
<Item onClick={() => updateSearch({ type: 'profiles', search })}> <Item onClick={() => updateSearch({ type: 'profiles', search })}>
<div className="font-semibold">{t('Show more...')}</div> <div className="font-semibold">{t('Show more...')}</div>
@@ -259,18 +260,8 @@ function ProfileIdItem({ id, onClick }: { id: string; onClick?: () => void }) {
function ProfileItem({ profile, onClick }: { profile: TProfile; onClick?: () => void }) { function ProfileItem({ profile, onClick }: { profile: TProfile; onClick?: () => void }) {
return ( return (
<div className="p-2 hover:bg-accent rounded-md cursor-pointer" onClick={onClick}> <div className="px-2 hover:bg-accent rounded-md cursor-pointer" onClick={onClick}>
<div className="flex gap-2 items-center pointer-events-none h-11"> <UserItem pubkey={profile.pubkey} hideFollowButton className="pointer-events-none" />
<UserAvatar userId={profile.pubkey} className="shrink-0" />
<div className="w-full overflow-hidden">
<Username
userId={profile.pubkey}
className="font-semibold truncate max-w-full w-fit"
skeletonClassName="h-4"
/>
<Nip05 pubkey={profile.pubkey} />
</div>
</div>
</div> </div>
) )
} }

View File

@@ -3,10 +3,19 @@ import Nip05 from '@/components/Nip05'
import UserAvatar from '@/components/UserAvatar' import UserAvatar from '@/components/UserAvatar'
import Username from '@/components/Username' import Username from '@/components/Username'
import { Skeleton } from '@/components/ui/skeleton' import { Skeleton } from '@/components/ui/skeleton'
import { cn } from '@/lib/utils'
export default function UserItem({ pubkey }: { pubkey: string }) { export default function UserItem({
pubkey,
hideFollowButton,
className
}: {
pubkey: string
hideFollowButton?: boolean
className?: string
}) {
return ( return (
<div className="flex gap-2 items-center h-14"> <div className={cn('flex gap-2 items-center h-14', className)}>
<UserAvatar userId={pubkey} className="shrink-0" /> <UserAvatar userId={pubkey} className="shrink-0" />
<div className="w-full overflow-hidden"> <div className="w-full overflow-hidden">
<Username <Username
@@ -16,7 +25,7 @@ export default function UserItem({ pubkey }: { pubkey: string }) {
/> />
<Nip05 pubkey={pubkey} /> <Nip05 pubkey={pubkey} />
</div> </div>
<FollowButton pubkey={pubkey} /> {!hideFollowButton && <FollowButton pubkey={pubkey} />}
</div> </div>
) )
} }

View File

@@ -1,5 +1,4 @@
import Relay from '@/components/Relay' import Relay from '@/components/Relay'
import RelayPageControls from '@/components/RelayPageControls'
import PrimaryPageLayout from '@/layouts/PrimaryPageLayout' import PrimaryPageLayout from '@/layouts/PrimaryPageLayout'
import { normalizeUrl, simplifyUrl } from '@/lib/url' import { normalizeUrl, simplifyUrl } from '@/lib/url'
import { useCurrentRelays } from '@/providers/CurrentRelaysProvider' import { useCurrentRelays } from '@/providers/CurrentRelaysProvider'
@@ -32,14 +31,9 @@ export default RelayPage
function RelayPageTitlebar({ url }: { url?: string }) { function RelayPageTitlebar({ url }: { url?: string }) {
return ( return (
<div className="flex gap-2 items-center justify-between h-full"> <div className="flex items-center gap-2 px-3 h-full">
<div className="flex items-center gap-2 pl-3 flex-1 w-0"> <Server />
<Server /> <div className="text-lg font-semibold truncate">{simplifyUrl(url ?? '')}</div>
<div className="text-lg font-semibold truncate">{simplifyUrl(url ?? '')}</div>
</div>
<div className="flex items-center flex-shrink-0">
<RelayPageControls url={url ?? ''} />
</div>
</div> </div>
) )
} }

View File

@@ -1,5 +1,4 @@
import Relay from '@/components/Relay' import Relay from '@/components/Relay'
import RelayPageControls from '@/components/RelayPageControls'
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout' import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
import { normalizeUrl, simplifyUrl } from '@/lib/url' import { normalizeUrl, simplifyUrl } from '@/lib/url'
import { forwardRef, useMemo } from 'react' import { forwardRef, useMemo } from 'react'
@@ -14,13 +13,7 @@ const RelayPage = forwardRef(({ url, index }: { url?: string; index?: number },
} }
return ( return (
<SecondaryPageLayout <SecondaryPageLayout ref={ref} index={index} title={title} displayScrollToTopButton>
ref={ref}
index={index}
title={title}
controls={<RelayPageControls url={normalizedUrl} />}
displayScrollToTopButton
>
<Relay url={normalizedUrl} /> <Relay url={normalizedUrl} />
</SecondaryPageLayout> </SecondaryPageLayout>
) )

View File

@@ -6,7 +6,6 @@ type TPostSettings = {
isNsfw?: boolean isNsfw?: boolean
isPoll?: boolean isPoll?: boolean
pollCreateData?: TPollCreateData pollCreateData?: TPollCreateData
specifiedRelayUrls?: string[]
addClientTag?: boolean addClientTag?: boolean
} }