Browse Source

make relays in relay sets clickable

imwald
Silberengel 5 months ago
parent
commit
cbda6307a0
  1. 9
      src/components/FavoriteRelaysSetting/RelayUrl.tsx
  2. 10
      src/components/RelaySetCard/index.tsx
  3. 30
      src/constants.ts
  4. 8
      src/hooks/useSearchProfiles.tsx

9
src/components/FavoriteRelaysSetting/RelayUrl.tsx

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { toRelay } from '@/lib/link'
import { isWebsocketUrl, normalizeUrl } from '@/lib/url'
import { useSecondaryPage } from '@/PageManager'
import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider'
import { CircleX } from 'lucide-react'
import { useMemo, useState } from 'react'
@ -79,9 +81,14 @@ export default function RelayUrls({ relaySetId }: { relaySetId: string }) { @@ -79,9 +81,14 @@ export default function RelayUrls({ relaySetId }: { relaySetId: string }) {
}
function RelayUrl({ url, onRemove }: { url: string; onRemove: () => void }) {
const { push } = useSecondaryPage()
return (
<div className="flex items-center justify-between pl-1 pr-3">
<div className="flex gap-3 items-center flex-1 w-0">
<div
className="flex gap-3 items-center flex-1 w-0 cursor-pointer hover:bg-muted rounded px-2 py-1 -mx-2 -my-1"
onClick={() => push(toRelay(url))}
>
<RelayIcon url={url} className="w-4 h-4" iconSize={10} />
<div className="text-muted-foreground text-sm truncate">{url}</div>
</div>

10
src/components/RelaySetCard/index.tsx

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
import { TRelaySet } from '@/types'
import { toRelay } from '@/lib/link'
import { useSecondaryPage } from '@/PageManager'
import { ChevronDown, FolderClosed } from 'lucide-react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -66,12 +68,18 @@ function RelayUrlsExpandToggle({ @@ -66,12 +68,18 @@ function RelayUrlsExpandToggle({
}
function RelayUrls({ urls }: { urls: string[] }) {
const { push } = useSecondaryPage()
if (!urls) return null
return (
<div className="pl-1 space-y-1">
{urls.map((url) => (
<div key={url} className="flex items-center gap-3">
<div
key={url}
className="flex items-center gap-3 cursor-pointer hover:bg-muted rounded px-2 py-1 -mx-2 -my-1"
onClick={() => push(toRelay(url))}
>
<RelayIcon url={url} className="w-4 h-4" iconSize={10} />
<div className="text-muted-foreground text-sm truncate">{url}</div>
</div>

30
src/constants.ts

@ -60,11 +60,11 @@ export const ApplicationDataKey = { @@ -60,11 +60,11 @@ export const ApplicationDataKey = {
export const BIG_RELAY_URLS = [
'wss://theforest.nostr1.com',
'wss://orly-relay.imwald.eu',
'wss://thecitadel.nostr1.com/',
'wss://nostr.wine',
'wss://nostr.land/',
'wss://nostr.land',
'wss://nostr.wine/',
'wss://nostr.sovbit.host/',
'wss://nostr21.com'
'wss://nostr21.com',
'wss://thecitadel.nostr1.com/'
]
// Optimized relay list for read operations (includes aggregator)
@ -77,23 +77,27 @@ export const FAST_READ_RELAY_URLS = [ @@ -77,23 +77,27 @@ export const FAST_READ_RELAY_URLS = [
// Optimized relay list for write operations (no aggregator since it's read-only)
export const FAST_WRITE_RELAY_URLS = [
'wss://nostr.wine',
'wss://nostr.land',
'wss://damus.io/',
'wss://primal.net/',
'wss://freelay.sovbit.host/',
'wss://thecitadel.nostr1.com/'
]
export const SEARCHABLE_RELAY_URLS = [
'wss://relay.nostr.band/',
'wss://freelay.sovbit.host/',
'wss://relay.damus.io/',
'wss://search.nos.today/',
'wss://aggr.nostr.land',
'wss://purplepag.es',
'wss://profiles.nostr1.com']
'wss://search.nos.today/',
'wss://nostr.wine',
'wss://orly-relay.imwald.eu',
'wss://aggr.nostr.land'
]
export const PROFILE_RELAY_URLS = [
'wss://purplepag.es',
'wss://profiles.nostr1.com'
]
// Combined relay URLs for profile fetching - includes both BIG_RELAY_URLS and SEARCHABLE_RELAY_URLS
export const PROFILE_FETCH_RELAY_URLS = [...BIG_RELAY_URLS, ...SEARCHABLE_RELAY_URLS]
export const PROFILE_FETCH_RELAY_URLS = [...SEARCHABLE_RELAY_URLS, ...PROFILE_RELAY_URLS]
export const GROUP_METADATA_EVENT_KIND = 39000

8
src/hooks/useSearchProfiles.tsx

@ -1,13 +1,9 @@ @@ -1,13 +1,9 @@
import { SEARCHABLE_RELAY_URLS } from '@/constants'
import { useFeed } from '@/providers/FeedProvider'
import client from '@/services/client.service'
import { TProfile } from '@/types'
import { useEffect, useState } from 'react'
import { useFetchRelayInfos } from './useFetchRelayInfos'
export function useSearchProfiles(search: string, limit: number) {
const { relayUrls } = useFeed()
const { searchableRelayUrls } = useFetchRelayInfos(relayUrls)
const [isFetching, setIsFetching] = useState(true)
const [error, setError] = useState<Error | null>(null)
const [profiles, setProfiles] = useState<TProfile[]>([])
@ -29,7 +25,7 @@ export function useSearchProfiles(search: string, limit: number) { @@ -29,7 +25,7 @@ export function useSearchProfiles(search: string, limit: number) {
}
const existingPubkeys = new Set(profiles.map((profile) => profile.pubkey))
const fetchedProfiles = await client.searchProfiles(
searchableRelayUrls.concat(SEARCHABLE_RELAY_URLS).slice(0, 4),
SEARCHABLE_RELAY_URLS,
{
search,
limit
@ -53,7 +49,7 @@ export function useSearchProfiles(search: string, limit: number) { @@ -53,7 +49,7 @@ export function useSearchProfiles(search: string, limit: number) {
}
fetchProfiles()
}, [searchableRelayUrls, search, limit])
}, [search, limit])
return { isFetching, error, profiles }
}

Loading…
Cancel
Save