import debounce from 'lodash/debounce'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { useDispatch } from 'react-redux'; import { fetchSuggestions } from 'soapbox/actions/suggestions'; import ScrollableList from 'soapbox/components/scrollable_list'; import { Button, Card, CardBody, Stack, Text } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account_container'; import { useAppSelector } from 'soapbox/hooks'; const SuggestedAccountsStep = ({ onNext }: { onNext: () => void }) => { const dispatch = useDispatch(); const suggestions = useAppSelector((state) => state.suggestions.items); const hasMore = useAppSelector((state) => !!state.suggestions.next); const isLoading = useAppSelector((state) => state.suggestions.isLoading); const handleLoadMore = debounce(() => { if (isLoading) { return null; } return dispatch(fetchSuggestions()); }, 300); React.useEffect(() => { dispatch(fetchSuggestions({ limit: 20 })); }, []); const renderSuggestions = () => { return (
{suggestions.map((suggestion) => (
, but it isn't id={suggestion.account} showProfileHoverCard={false} withLinkToProfile={false} />
))}
); }; const renderEmpty = () => { return (
); }; const renderBody = () => { if (suggestions.isEmpty()) { return renderEmpty(); } else { return renderSuggestions(); } }; return (
{renderBody()}
); }; export default SuggestedAccountsStep;