import debounce from 'lodash/debounce'; import React, { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { fetchSuggestions } from 'soapbox/actions/suggestions'; import ScrollableList from 'soapbox/components/scrollable-list'; import { Stack, Text } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account-container'; import Column from 'soapbox/features/ui/components/column'; import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; const messages = defineMessages({ heading: { id: 'followRecommendations.heading', defaultMessage: 'Suggested Profiles' }, }); const FollowRecommendations: React.FC = () => { const dispatch = useAppDispatch(); const intl = useIntl(); const features = useFeatures(); 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({ limit: 20 })); }, 300); useEffect(() => { dispatch(fetchSuggestions({ limit: 20 })); }, []); if (suggestions.size === 0 && !isLoading) { return ( ); } return ( {features.truthSuggestions ? ( suggestions.map((suggestedProfile) => ( )) ) : ( suggestions.map((suggestion) => ( )) )} ); }; export default FollowRecommendations;