Browse Source

fix: 🐛

imwald
codytseng 1 year ago
parent
commit
dae923ee38
  1. 21
      src/hooks/useSearchProfiles.tsx

21
src/hooks/useSearchProfiles.tsx

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
import { SEARCHABLE_RELAY_URLS } from '@/constants'
import { useFeed } from '@/providers/FeedProvider'
import client from '@/services/client.service'
import { TProfile } from '@/types'
@ -13,19 +14,21 @@ export function useSearchProfiles(search: string, limit: number) { @@ -13,19 +14,21 @@ export function useSearchProfiles(search: string, limit: number) {
useEffect(() => {
const fetchProfiles = async () => {
if (!search) return
if (!search) {
setProfiles([])
return
}
setIsFetching(true)
setProfiles([])
if (searchableRelayUrls.length === 0) {
setIsFetching(false)
return
}
try {
const profiles = await client.fetchProfiles(searchableRelayUrls, {
search,
limit
})
const profiles = await client.fetchProfiles(
searchableRelayUrls.length > 0 ? searchableRelayUrls : SEARCHABLE_RELAY_URLS,
{
search,
limit
}
)
if (profiles) {
setProfiles(profiles)
}

Loading…
Cancel
Save