blog post and other fixes/additions #124
@ -21,7 +21,8 @@ import {
|
|||||||
log,
|
log,
|
||||||
LogType,
|
LogType,
|
||||||
npubToHex,
|
npubToHex,
|
||||||
orderEventsChronologically
|
orderEventsChronologically,
|
||||||
|
timeout
|
||||||
} from 'utils'
|
} from 'utils'
|
||||||
|
|
||||||
type FetchModsOptions = {
|
type FetchModsOptions = {
|
||||||
@ -241,8 +242,11 @@ export const NDKContextProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
hexKey: string,
|
hexKey: string,
|
||||||
userRelaysType: UserRelaysType
|
userRelaysType: UserRelaysType
|
||||||
): Promise<NDKEvent[]> => {
|
): Promise<NDKEvent[]> => {
|
||||||
// Find the user's relays.
|
// Find the user's relays (10s timeout).
|
||||||
const relayUrls = await getRelayListForUser(hexKey, ndk)
|
const relayUrls = await Promise.race([
|
||||||
|
getRelayListForUser(hexKey, ndk),
|
||||||
|
timeout(10000)
|
||||||
|
])
|
||||||
.then((ndkRelayList) => {
|
.then((ndkRelayList) => {
|
||||||
if (ndkRelayList) return ndkRelayList[userRelaysType]
|
if (ndkRelayList) return ndkRelayList[userRelaysType]
|
||||||
return [] // Return an empty array if ndkRelayList is undefined
|
return [] // Return an empty array if ndkRelayList is undefined
|
||||||
|
@ -5,7 +5,7 @@ import { Event, kinds, UnsignedEvent } from 'nostr-tools'
|
|||||||
import { useMemo, useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import { UserRelaysType } from 'types'
|
import { UserRelaysType } from 'types'
|
||||||
import { abbreviateNumber, log, LogType, now } from 'utils'
|
import { abbreviateNumber, log, LogType, now, timeout } from 'utils'
|
||||||
|
|
||||||
type UseReactionsParams = {
|
type UseReactionsParams = {
|
||||||
pubkey: string
|
pubkey: string
|
||||||
@ -32,7 +32,11 @@ export const useReactions = (params: UseReactionsParams) => {
|
|||||||
filter['#e'] = [params.eTag]
|
filter['#e'] = [params.eTag]
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchEventsFromUserRelays(filter, params.pubkey, UserRelaysType.Read)
|
// 1 minute timeout
|
||||||
|
Promise.race([
|
||||||
|
fetchEventsFromUserRelays(filter, params.pubkey, UserRelaysType.Read),
|
||||||
|
timeout(60000)
|
||||||
|
])
|
||||||
.then((events) => {
|
.then((events) => {
|
||||||
setReactionEvents(events)
|
setReactionEvents(events)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user