From d189d51e26775691d28e54121dad351c04d71759 Mon Sep 17 00:00:00 2001 From: codytseng Date: Mon, 1 Sep 2025 22:31:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Note/index.tsx | 2 +- src/components/ProfileListBySearch/index.tsx | 12 ++++++++++-- src/components/SearchBar/index.tsx | 14 +++++++------- src/components/UserItem/index.tsx | 15 +++++++++++++++ src/pages/secondary/MuteListPage/index.tsx | 2 +- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/components/Note/index.tsx b/src/components/Note/index.tsx index 9984baa8..1d4b70e0 100644 --- a/src/components/Note/index.tsx +++ b/src/components/Note/index.tsx @@ -108,7 +108,7 @@ export default function Note({
-
+
()) const bottomRef = useRef(null) + useEffect(() => { + setUntil(dayjs().unix()) + setHasMore(true) + setPubkeySet(new Set()) + 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) => ( ))} + {hasMore && } {hasMore &&
}
) diff --git a/src/components/SearchBar/index.tsx b/src/components/SearchBar/index.tsx index eb33373d..aa2bc80c 100644 --- a/src/components/SearchBar/index.tsx +++ b/src/components/SearchBar/index.tsx @@ -1,6 +1,5 @@ import Nip05 from '@/components/Nip05' import SearchInput from '@/components/SearchInput' -import { ScrollArea } from '@/components/ui/scroll-area' import UserAvatar from '@/components/UserAvatar' import Username from '@/components/Username' import { useSearchProfiles } from '@/hooks' @@ -24,6 +23,7 @@ import { useState } from 'react' import { useTranslation } from 'react-i18next' +import { UserItemSkeleton } from '../UserItem' const SearchBar = forwardRef< TSearchBarRef, @@ -37,7 +37,7 @@ const SearchBar = forwardRef< const { push } = useSecondaryPage() const { isSmallScreen } = useScreenSize() const [debouncedInput, setDebouncedInput] = useState(input) - const { profiles } = useSearchProfiles(debouncedInput, 10) + const { profiles, isFetching: isFetchingProfiles } = useSearchProfiles(debouncedInput, 5) const [searching, setSearching] = useState(false) const searchInputRef = useRef(null) const normalizedUrl = useMemo(() => { @@ -154,7 +154,8 @@ const SearchBar = forwardRef< } /> ))} - {profiles.length >= 10 && ( + {isFetchingProfiles && profiles.length < 5 && } + {profiles.length >= 5 && ( updateSearch({ type: 'profiles', search })}>
{t('Show more...')}
@@ -179,16 +180,15 @@ const SearchBar = forwardRef< <>
e.preventDefault()} > {list ? ( - {list} +
{list}
) : (
{t('Type searching for people, keywords, or relays')} diff --git a/src/components/UserItem/index.tsx b/src/components/UserItem/index.tsx index b0d59381..1ace83d4 100644 --- a/src/components/UserItem/index.tsx +++ b/src/components/UserItem/index.tsx @@ -2,6 +2,7 @@ import FollowButton from '@/components/FollowButton' import Nip05 from '@/components/Nip05' import UserAvatar from '@/components/UserAvatar' import Username from '@/components/Username' +import { Skeleton } from '@/components/ui/skeleton' export default function UserItem({ pubkey }: { pubkey: string }) { return ( @@ -19,3 +20,17 @@ export default function UserItem({ pubkey }: { pubkey: string }) {
) } + +export function UserItemSkeleton({ hideFollowButton }: { hideFollowButton?: boolean }) { + return ( +
+ +
+
+ +
+
+ {!hideFollowButton && } +
+ ) +} diff --git a/src/pages/secondary/MuteListPage/index.tsx b/src/pages/secondary/MuteListPage/index.tsx index e8723c8c..a3a15949 100644 --- a/src/pages/secondary/MuteListPage/index.tsx +++ b/src/pages/secondary/MuteListPage/index.tsx @@ -63,7 +63,7 @@ const MuteListPage = forwardRef(({ index }: { index?: number }, ref) => { title={t("username's muted", { username: profile.username })} displayScrollToTopButton > -
+
{visibleMutePubkeys.map((pubkey, index) => ( ))}