feat: default to publishing posts only to outbox/inbox relays
This commit is contained in:
@@ -137,7 +137,7 @@ export default function ReplyNoteList({ index, event }: { index?: number; event:
|
||||
rootInfo.type === 'E'
|
||||
? client.getSeenEventRelayUrls(rootInfo.id)
|
||||
: rootInfo.type === 'A'
|
||||
? client.getCurrentRelayUrls()
|
||||
? client.getSeenEventRelayUrls(rootInfo.eventId)
|
||||
: []
|
||||
relayUrls.unshift(...seenOn)
|
||||
|
||||
@@ -317,7 +317,7 @@ export default function ReplyNoteList({ index, event }: { index?: number; event:
|
||||
})}
|
||||
</div>
|
||||
{!loading && (
|
||||
<div className="text-sm mt-2 text-center text-muted-foreground">
|
||||
<div className="text-sm mt-2 mb-3 text-center text-muted-foreground">
|
||||
{replies.length > 0 ? t('no more replies') : t('no replies')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { DEFAULT_FAVORITE_RELAYS } from '@/constants'
|
||||
import { getRelaySetFromEvent } from '@/lib/event-metadata'
|
||||
import { checkAlgoRelay } from '@/lib/relay'
|
||||
import { isWebsocketUrl, normalizeUrl } from '@/lib/url'
|
||||
import client from '@/services/client.service'
|
||||
import indexedDb from '@/services/indexed-db.service'
|
||||
import storage from '@/services/local-storage.service'
|
||||
import relayInfoService from '@/services/relay-info.service'
|
||||
import { TFeedInfo, TFeedType } from '@/types'
|
||||
import { kinds } from 'nostr-tools'
|
||||
import { createContext, useContext, useEffect, useRef, useState } from 'react'
|
||||
@@ -103,9 +100,6 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
|
||||
setRelayUrls([normalizedUrl])
|
||||
storage.setFeedInfo(newFeedInfo, pubkey)
|
||||
setIsReady(true)
|
||||
|
||||
const relayInfo = await relayInfoService.getRelayInfo(normalizedUrl)
|
||||
client.setCurrentRelayUrls(checkAlgoRelay(relayInfo) ? [] : [normalizedUrl])
|
||||
return
|
||||
}
|
||||
if (feedType === 'relays') {
|
||||
@@ -135,11 +129,6 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
|
||||
setRelayUrls(relaySet.relayUrls)
|
||||
storage.setFeedInfo(newFeedInfo, pubkey)
|
||||
setIsReady(true)
|
||||
|
||||
const relayInfos = await relayInfoService.getRelayInfos(relaySet.relayUrls)
|
||||
client.setCurrentRelayUrls(
|
||||
relaySet.relayUrls.filter((_, i) => !relayInfos[i] || !checkAlgoRelay(relayInfos[i]))
|
||||
)
|
||||
}
|
||||
setIsReady(true)
|
||||
return
|
||||
|
||||
@@ -649,9 +649,9 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
|
||||
relays = specifiedRelayUrls
|
||||
} else {
|
||||
const relayList = await client.fetchRelayList(event.pubkey)
|
||||
relays = (relayList?.write.slice(0, 10) ?? [])
|
||||
.concat(Array.from(new Set(_additionalRelayUrls)) ?? [])
|
||||
.concat(client.getCurrentRelayUrls())
|
||||
relays = (relayList?.write.slice(0, 10) ?? []).concat(
|
||||
Array.from(new Set(_additionalRelayUrls)) ?? []
|
||||
)
|
||||
}
|
||||
|
||||
if (!relays.length) {
|
||||
|
||||
@@ -35,7 +35,6 @@ class ClientService extends EventTarget {
|
||||
|
||||
signer?: ISigner
|
||||
pubkey?: string
|
||||
private currentRelayUrls: string[] = []
|
||||
private pool: SimplePool
|
||||
|
||||
private timelines: Record<
|
||||
@@ -81,14 +80,6 @@ class ClientService extends EventTarget {
|
||||
await indexedDb.iterateProfileEvents((profileEvent) => this.addUsernameToIndex(profileEvent))
|
||||
}
|
||||
|
||||
setCurrentRelayUrls(urls: string[]) {
|
||||
this.currentRelayUrls = urls
|
||||
}
|
||||
|
||||
getCurrentRelayUrls() {
|
||||
return this.currentRelayUrls
|
||||
}
|
||||
|
||||
async publishEvent(relayUrls: string[], event: NEvent) {
|
||||
try {
|
||||
const uniqueRelayUrls = Array.from(new Set(relayUrls))
|
||||
@@ -626,11 +617,7 @@ class ClientService extends EventTarget {
|
||||
} = {}
|
||||
) {
|
||||
const relays = Array.from(new Set(urls))
|
||||
const events = await this.query(
|
||||
relays.length > 0 ? relays : this.currentRelayUrls.concat(BIG_RELAY_URLS),
|
||||
filter,
|
||||
onevent
|
||||
)
|
||||
const events = await this.query(relays.length > 0 ? relays : BIG_RELAY_URLS, filter, onevent)
|
||||
if (cache) {
|
||||
events.forEach((evt) => {
|
||||
this.addEventToCache(evt)
|
||||
|
||||
Reference in New Issue
Block a user