fix: 🐛
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
||||
import { getParentEventId, getRootEventId } from '@/lib/event'
|
||||
import { toNote } from '@/lib/link'
|
||||
import { useMemo } from 'react'
|
||||
import NotFoundPage from '../NotFoundPage'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import NotFoundPage from '../NotFoundPage'
|
||||
|
||||
export default function NotePage({ id }: { id?: string }) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -24,7 +24,7 @@ import QrCodePopover from './QrCodePopover'
|
||||
export default function ProfilePage({ id }: { id?: string }) {
|
||||
const { t } = useTranslation()
|
||||
const { profile, isFetching } = useFetchProfile(id)
|
||||
const relayList = useFetchRelayList(profile?.pubkey)
|
||||
const { relayList, isFetching: isFetchingRelayInfo } = useFetchRelayList(profile?.pubkey)
|
||||
const { relayUrls: currentRelayUrls } = useRelaySettings()
|
||||
const { pubkey: accountPubkey } = useNostr()
|
||||
const { followings: selfFollowings } = useFollowList()
|
||||
@@ -99,12 +99,13 @@ export default function ProfilePage({ id }: { id?: string }) {
|
||||
</div>
|
||||
</div>
|
||||
<Separator className="hidden sm:block mt-4 sm:my-4" />
|
||||
{!isFetchingRelayInfo && (
|
||||
<NoteList
|
||||
key={pubkey}
|
||||
filter={{ authors: [pubkey] }}
|
||||
relayUrls={relayList.write.slice(0, 5).concat(currentRelayUrls)}
|
||||
className="max-sm:mt-2"
|
||||
/>
|
||||
)}
|
||||
</SecondaryPageLayout>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
|
||||
const [signer, setSigner] = useState<ISigner | null>(null)
|
||||
const [openLoginDialog, setOpenLoginDialog] = useState(false)
|
||||
const { relayUrls: currentRelayUrls } = useRelaySettings()
|
||||
const relayList = useFetchRelayList(account?.pubkey)
|
||||
const { relayList } = useFetchRelayList(account?.pubkey)
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
|
||||
Reference in New Issue
Block a user