fix: 🐛
This commit is contained in:
parent
31f70c2ab1
commit
b5174df32c
4 changed files with 19 additions and 11 deletions
|
|
@ -4,20 +4,27 @@ import client from '@/services/client.service'
|
|||
|
||||
export function useFetchRelayList(pubkey?: string | null) {
|
||||
const [relayList, setRelayList] = useState<TRelayList>({ write: [], read: [] })
|
||||
const [isFetching, setIsFetching] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const fetchRelayList = async () => {
|
||||
if (!pubkey) return
|
||||
setIsFetching(true)
|
||||
if (!pubkey) {
|
||||
setIsFetching(false)
|
||||
return
|
||||
}
|
||||
try {
|
||||
const relayList = await client.fetchRelayList(pubkey)
|
||||
setRelayList(relayList)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
} finally {
|
||||
setIsFetching(false)
|
||||
}
|
||||
}
|
||||
|
||||
fetchRelayList()
|
||||
}, [pubkey])
|
||||
|
||||
return relayList
|
||||
return { relayList, isFetching }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue