import classNames from 'clsx'; import React, { useCallback, useState } from 'react'; import { Virtuoso } from 'react-virtuoso'; import { Avatar, HStack, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification-badge'; import useAccountSearch from 'soapbox/queries/search'; interface IResults { accountSearchResult: ReturnType onSelect(id: string): void } const Results = ({ accountSearchResult, onSelect }: IResults) => { const { data: accounts, isFetching, hasNextPage, fetchNextPage } = accountSearchResult; const [isNearBottom, setNearBottom] = useState(false); const [isNearTop, setNearTop] = useState(true); const handleLoadMore = () => { if (hasNextPage && !isFetching) { fetchNextPage(); } }; const renderAccount = useCallback((_index, account) => ( ), []); return (
(
{renderAccount(index, chat)}
)} endReached={handleLoadMore} atTopStateChange={(atTop) => setNearTop(atTop)} atBottomStateChange={(atBottom) => setNearBottom(atBottom)} /> <>
); }; export default Results;