feat: add default search relays
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -16,7 +16,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
||||||
"@radix-ui/react-hover-card": "^1.1.4",
|
"@radix-ui/react-hover-card": "^1.1.4",
|
||||||
"@radix-ui/react-popover": "^1.1.4",
|
"@radix-ui/react-popover": "^1.1.4",
|
||||||
"@radix-ui/react-scroll-area": "^1.2.0",
|
"@radix-ui/react-scroll-area": "1.2.0",
|
||||||
"@radix-ui/react-separator": "^1.1.1",
|
"@radix-ui/react-separator": "^1.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.1",
|
"@radix-ui/react-slot": "^1.1.1",
|
||||||
"@radix-ui/react-switch": "^1.1.2",
|
"@radix-ui/react-switch": "^1.1.2",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
||||||
"@radix-ui/react-hover-card": "^1.1.4",
|
"@radix-ui/react-hover-card": "^1.1.4",
|
||||||
"@radix-ui/react-popover": "^1.1.4",
|
"@radix-ui/react-popover": "^1.1.4",
|
||||||
"@radix-ui/react-scroll-area": "^1.2.0",
|
"@radix-ui/react-scroll-area": "1.2.0",
|
||||||
"@radix-ui/react-separator": "^1.1.1",
|
"@radix-ui/react-separator": "^1.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.1",
|
"@radix-ui/react-slot": "^1.1.1",
|
||||||
"@radix-ui/react-switch": "^1.1.2",
|
"@radix-ui/react-switch": "^1.1.2",
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export default function NoteList({
|
|||||||
}
|
}
|
||||||
pullingContent=""
|
pullingContent=""
|
||||||
>
|
>
|
||||||
<>
|
<div className="space-y-2 sm:space-y-4">
|
||||||
{newEvents.filter((event) => displayReplies || !isReplyNoteEvent(event)).length > 0 && (
|
{newEvents.filter((event) => displayReplies || !isReplyNoteEvent(event)).length > 0 && (
|
||||||
<div className="flex justify-center w-full max-sm:mt-2">
|
<div className="flex justify-center w-full max-sm:mt-2">
|
||||||
<Button size="lg" onClick={showNewEvents}>
|
<Button size="lg" onClick={showNewEvents}>
|
||||||
@@ -175,7 +175,7 @@ export default function NoteList({
|
|||||||
<NoteCard key={event.id} className="w-full" event={event} />
|
<NoteCard key={event.id} className="w-full" event={event} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
</PullToRefresh>
|
</PullToRefresh>
|
||||||
<div className="text-center text-sm text-muted-foreground">
|
<div className="text-center text-sm text-muted-foreground">
|
||||||
{hasMore ? (
|
{hasMore ? (
|
||||||
|
|||||||
@@ -3,3 +3,12 @@ export const StorageKey = {
|
|||||||
RELAY_GROUPS: 'relayGroups',
|
RELAY_GROUPS: 'relayGroups',
|
||||||
ACCOUNTS: 'accounts'
|
ACCOUNTS: 'accounts'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const BIG_RELAY_URLS = [
|
||||||
|
'wss://relay.damus.io/',
|
||||||
|
'wss://nos.lol/',
|
||||||
|
'wss://relay.nostr.band/',
|
||||||
|
'wss://relay.noswhere.com/'
|
||||||
|
]
|
||||||
|
|
||||||
|
export const SEARCHABLE_RELAY_URLS = ['wss://relay.nostr.band/', 'wss://search.nos.today/']
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { TRelayGroup } from '@/types'
|
import { SEARCHABLE_RELAY_URLS } from '@/constants'
|
||||||
import { checkAlgoRelay, checkSearchRelay } from '@/lib/relay'
|
import { checkAlgoRelay, checkSearchRelay } from '@/lib/relay'
|
||||||
import { isWebsocketUrl, normalizeUrl } from '@/lib/url'
|
import { isWebsocketUrl, normalizeUrl } from '@/lib/url'
|
||||||
import client from '@/services/client.service'
|
import client from '@/services/client.service'
|
||||||
import storage from '@/services/storage.service'
|
import storage from '@/services/storage.service'
|
||||||
|
import { TRelayGroup } from '@/types'
|
||||||
import { createContext, Dispatch, useContext, useEffect, useState } from 'react'
|
import { createContext, Dispatch, useContext, useEffect, useState } from 'react'
|
||||||
|
|
||||||
type TRelaySettingsContext = {
|
type TRelaySettingsContext = {
|
||||||
@@ -37,7 +38,7 @@ export function RelaySettingsProvider({ children }: { children: React.ReactNode
|
|||||||
? temporaryRelayUrls
|
? temporaryRelayUrls
|
||||||
: (relayGroups.find((group) => group.isActive)?.relayUrls ?? [])
|
: (relayGroups.find((group) => group.isActive)?.relayUrls ?? [])
|
||||||
)
|
)
|
||||||
const [searchableRelayUrls, setSearchableRelayUrls] = useState<string[]>([])
|
const [searchableRelayUrls, setSearchableRelayUrls] = useState<string[]>(SEARCHABLE_RELAY_URLS)
|
||||||
const [areAlgoRelays, setAreAlgoRelays] = useState(false)
|
const [areAlgoRelays, setAreAlgoRelays] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -63,7 +64,12 @@ export function RelaySettingsProvider({ children }: { children: React.ReactNode
|
|||||||
setRelayUrls(newRelayUrls)
|
setRelayUrls(newRelayUrls)
|
||||||
}
|
}
|
||||||
const relayInfos = await client.fetchRelayInfos(newRelayUrls)
|
const relayInfos = await client.fetchRelayInfos(newRelayUrls)
|
||||||
setSearchableRelayUrls(newRelayUrls.filter((_, index) => checkSearchRelay(relayInfos[index])))
|
const searchableRelayUrls = newRelayUrls.filter((_, index) =>
|
||||||
|
checkSearchRelay(relayInfos[index])
|
||||||
|
)
|
||||||
|
setSearchableRelayUrls(
|
||||||
|
searchableRelayUrls.length ? searchableRelayUrls : SEARCHABLE_RELAY_URLS
|
||||||
|
)
|
||||||
const nonAlgoRelayUrls = newRelayUrls.filter((_, index) => !checkAlgoRelay(relayInfos[index]))
|
const nonAlgoRelayUrls = newRelayUrls.filter((_, index) => !checkAlgoRelay(relayInfos[index]))
|
||||||
setAreAlgoRelays(newRelayUrls.length > 0 && nonAlgoRelayUrls.length === 0)
|
setAreAlgoRelays(newRelayUrls.length > 0 && nonAlgoRelayUrls.length === 0)
|
||||||
client.setCurrentRelayUrls(nonAlgoRelayUrls)
|
client.setCurrentRelayUrls(nonAlgoRelayUrls)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { BIG_RELAY_URLS } from '@/constants'
|
||||||
import { formatPubkey } from '@/lib/pubkey'
|
import { formatPubkey } from '@/lib/pubkey'
|
||||||
import { tagNameEquals } from '@/lib/tag'
|
import { tagNameEquals } from '@/lib/tag'
|
||||||
import { isWebsocketUrl, normalizeUrl } from '@/lib/url'
|
import { isWebsocketUrl, normalizeUrl } from '@/lib/url'
|
||||||
@@ -15,13 +16,6 @@ import {
|
|||||||
VerifiedEvent
|
VerifiedEvent
|
||||||
} from 'nostr-tools'
|
} from 'nostr-tools'
|
||||||
|
|
||||||
const BIG_RELAY_URLS = [
|
|
||||||
'wss://relay.damus.io/',
|
|
||||||
'wss://nos.lol/',
|
|
||||||
'wss://relay.nostr.band/',
|
|
||||||
'wss://relay.noswhere.com/'
|
|
||||||
]
|
|
||||||
|
|
||||||
type TTimelineRef = [string, number]
|
type TTimelineRef = [string, number]
|
||||||
|
|
||||||
class ClientService extends EventTarget {
|
class ClientService extends EventTarget {
|
||||||
|
|||||||
Reference in New Issue
Block a user