import { Map as ImmutableMap } from 'immutable'; 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.get('items')); const hasMore = useAppSelector((state) => !!state.suggestions.get('next')); const isLoading = useAppSelector((state) => state.suggestions.get('isLoading')); const handleLoadMore = debounce(() => { if (isLoading) { return null; } return dispatch(fetchSuggestions()); }, 300); React.useEffect(() => { dispatch(fetchSuggestions({ limit: 20 })); }, []); const renderSuggestions = () => { return (
{suggestions.map((suggestion: ImmutableMap) => (
, but it isn't id={suggestion.get('account')} showProfileHoverCard={false} />
))}
); }; const renderEmpty = () => { return (
); }; const renderBody = () => { if (suggestions.isEmpty()) { return renderEmpty(); } else { return renderSuggestions(); } }; return (
{renderBody()}
); }; export default SuggestedAccountsStep;