From 9b822a6c12224b23f97517693ff2041da9b6fce4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 17 Sep 2021 17:09:37 -0500 Subject: [PATCH] Suggestions: display suggestions on Home timeline when there are no posts --- app/soapbox/features/home_timeline/index.js | 76 +++++++++++++++++---- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/app/soapbox/features/home_timeline/index.js b/app/soapbox/features/home_timeline/index.js index e48067ed6..71a146549 100644 --- a/app/soapbox/features/home_timeline/index.js +++ b/app/soapbox/features/home_timeline/index.js @@ -4,20 +4,35 @@ import { expandHomeTimeline } from '../../actions/timelines'; import PropTypes from 'prop-types'; import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; +import BundleContainer from 'soapbox/features/ui/containers/bundle_container'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import ColumnSettingsContainer from './containers/column_settings_container'; import HomeColumnHeader from '../../components/home_column_header'; import { Link } from 'react-router-dom'; +import Button from 'soapbox/components/button'; +import { OrderedSet as ImmutableOrderedSet } from 'immutable'; +import { getFeatures } from 'soapbox/utils/features'; + +function FollowRecommendationsList() { + return import(/* webpackChunkName: "features/follow_recommendations" */'soapbox/features/follow_recommendations/components/follow_recommendations_list'); +} const messages = defineMessages({ title: { id: 'column.home', defaultMessage: 'Home' }, }); -const mapStateToProps = state => ({ - hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0, - isPartial: state.getIn(['timelines', 'home', 'isPartial']), - siteTitle: state.getIn(['instance', 'title']), -}); +const mapStateToProps = state => { + const instance = state.get('instance'); + const features = getFeatures(instance); + + return { + hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0, + isPartial: state.getIn(['timelines', 'home', 'isPartial']), + siteTitle: state.getIn(['instance', 'title']), + isEmpty: state.getIn(['timelines', 'home', 'items'], ImmutableOrderedSet()).isEmpty(), + features, + }; +}; export default @connect(mapStateToProps) @injectIntl @@ -29,8 +44,14 @@ class HomeTimeline extends React.PureComponent { hasUnread: PropTypes.bool, isPartial: PropTypes.bool, siteTitle: PropTypes.string, + isEmpty: PropTypes.bool, + features: PropTypes.object.isRequired, }; + state = { + done: false, + } + handleLoadMore = maxId => { this.props.dispatch(expandHomeTimeline({ maxId })); } @@ -68,20 +89,51 @@ class HomeTimeline extends React.PureComponent { } } + handleDone = e => { + this.props.dispatch(expandHomeTimeline()); + this.setState({ done: true }); + } + + renderFollowRecommendations = () => { + return ( +
+
+

+

+
+ + + {Component => } + + +
+ +
+
+ ); + } + render() { - const { intl, hasUnread, siteTitle } = this.props; + const { intl, hasUnread, siteTitle, isEmpty, features } = this.props; + const { done } = this.state; return ( - }} />} - /> + {(features.suggestions && isEmpty && !done) ? ( + this.renderFollowRecommendations() + ) : ( + }} />} + /> + )} ); }