fix: 🐛

This commit is contained in:
codytseng
2025-09-01 22:31:32 +08:00
parent a1285fe44d
commit d189d51e26
5 changed files with 34 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ import { SEARCHABLE_RELAY_URLS } from '@/constants'
import client from '@/services/client.service'
import dayjs from 'dayjs'
import { useEffect, useRef, useState } from 'react'
import UserItem from '../UserItem'
import UserItem, { UserItemSkeleton } from '../UserItem'
const LIMIT = 50
@@ -12,6 +12,13 @@ export function ProfileListBySearch({ search }: { search: string }) {
const [pubkeySet, setPubkeySet] = useState(new Set<string>())
const bottomRef = useRef<HTMLDivElement>(null)
useEffect(() => {
setUntil(dayjs().unix())
setHasMore(true)
setPubkeySet(new Set<string>())
loadMore()
}, [search])
useEffect(() => {
if (!hasMore) return
const options = {
@@ -39,7 +46,7 @@ export function ProfileListBySearch({ search }: { search: string }) {
}
}, [hasMore, search, until])
async function loadMore() {
const loadMore = async () => {
const profiles = await client.searchProfiles(SEARCHABLE_RELAY_URLS, {
search,
until,
@@ -62,6 +69,7 @@ export function ProfileListBySearch({ search }: { search: string }) {
{Array.from(pubkeySet).map((pubkey, index) => (
<UserItem key={`${index}-${pubkey}`} pubkey={pubkey} />
))}
{hasMore && <UserItemSkeleton />}
{hasMore && <div ref={bottomRef} />}
</div>
)