diff --git a/app/soapbox/actions/suggestions.js b/app/soapbox/actions/suggestions.js index ede37ff303..c804c48555 100644 Binary files a/app/soapbox/actions/suggestions.js and b/app/soapbox/actions/suggestions.js differ diff --git a/app/soapbox/components/scrollable_list.tsx b/app/soapbox/components/scrollable_list.tsx index cc4b55867c..c2497547be 100644 --- a/app/soapbox/components/scrollable_list.tsx +++ b/app/soapbox/components/scrollable_list.tsx @@ -42,6 +42,8 @@ interface IScrollableList extends VirtuosoProps { onRefresh?: () => Promise, className?: string, itemClassName?: string, + style?: React.CSSProperties, + useWindowScroll?: boolean } /** Legacy ScrollableList with Virtuoso for backwards-compatibility */ @@ -63,6 +65,8 @@ const ScrollableList = React.forwardRef(({ placeholderCount = 0, initialTopMostItemIndex = 0, scrollerRef, + style = {}, + useWindowScroll = true, }, ref) => { const settings = useSettings(); const autoloadMore = settings.get('autoloadMore'); @@ -129,7 +133,7 @@ const ScrollableList = React.forwardRef(({ const renderFeed = (): JSX.Element => ( (({ isScrolling={isScrolling => isScrolling && onScroll && onScroll()} itemContent={renderItem} initialTopMostItemIndex={showLoading ? 0 : initialTopMostItemIndex} + style={style} context={{ listClassName: className, itemClassName, diff --git a/app/soapbox/features/onboarding/steps/suggested-accounts-step.tsx b/app/soapbox/features/onboarding/steps/suggested-accounts-step.tsx index d3972e1ab1..4421979cb7 100644 --- a/app/soapbox/features/onboarding/steps/suggested-accounts-step.tsx +++ b/app/soapbox/features/onboarding/steps/suggested-accounts-step.tsx @@ -1,8 +1,10 @@ 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 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'; @@ -13,24 +15,42 @@ const SuggestedAccountsStep = ({ onNext }: { onNext: () => void }) => { const dispatch = useDispatch(); const suggestions = useAppSelector((state) => state.suggestions.get('items')); - const suggestionsToRender = suggestions.slice(0, 5); + 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()); + dispatch(fetchSuggestions({ limit: 20 })); }, []); const renderSuggestions = () => { return ( -
- {suggestionsToRender.map((suggestion: ImmutableMap) => ( -
- , but it isn't - id={suggestion.get('account')} - showProfileHoverCard={false} - /> -
- ))} +
+ + {suggestions.map((suggestion: ImmutableMap) => ( +
+ , but it isn't + id={suggestion.get('account')} + showProfileHoverCard={false} + /> +
+ ))} +
); }; @@ -46,7 +66,7 @@ const SuggestedAccountsStep = ({ onNext }: { onNext: () => void }) => { }; const renderBody = () => { - if (suggestionsToRender.isEmpty()) { + if (suggestions.isEmpty()) { return renderEmpty(); } else { return renderSuggestions(); diff --git a/app/soapbox/reducers/__tests__/suggestions-test.js b/app/soapbox/reducers/__tests__/suggestions-test.js index 7da0b7f750..01c1f1affe 100644 Binary files a/app/soapbox/reducers/__tests__/suggestions-test.js and b/app/soapbox/reducers/__tests__/suggestions-test.js differ diff --git a/app/soapbox/reducers/suggestions.js b/app/soapbox/reducers/suggestions.js index ac00eecf11..03f782d3e7 100644 Binary files a/app/soapbox/reducers/suggestions.js and b/app/soapbox/reducers/suggestions.js differ