2023-04-23 20:24:53 +00:00
import PropTypes from 'prop-types' ;
2023-12-02 18:21:43 +00:00
import { PureComponent } from 'react' ;
import { FormattedMessage , FormattedHTMLMessage } from 'react-intl' ;
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2023-04-23 20:24:53 +00:00
import { connect } from 'react-redux' ;
2023-12-02 18:21:43 +00:00
2023-04-23 20:24:53 +00:00
import { fetchSuggestions } from 'flavours/glitch/actions/suggestions' ;
import { markAsPartial } from 'flavours/glitch/actions/timelines' ;
2023-12-02 18:21:43 +00:00
import Column from 'flavours/glitch/components/column' ;
import ColumnBackButton from 'flavours/glitch/components/column_back_button' ;
2023-05-11 05:55:10 +00:00
import { EmptyAccount } from 'flavours/glitch/components/empty_account' ;
2023-12-02 18:21:43 +00:00
import Account from 'flavours/glitch/containers/account_container' ;
2023-04-23 20:24:53 +00:00
import { me } from 'flavours/glitch/initial_state' ;
2023-12-02 18:21:43 +00:00
import { makeGetAccount } from 'flavours/glitch/selectors' ;
2023-04-23 20:24:53 +00:00
import ProgressIndicator from './components/progress_indicator' ;
const mapStateToProps = ( ) => {
const getAccount = makeGetAccount ( ) ;
return state => ( {
account : getAccount ( state , me ) ,
suggestions : state . getIn ( [ 'suggestions' , 'items' ] ) ,
isLoading : state . getIn ( [ 'suggestions' , 'isLoading' ] ) ,
} ) ;
} ;
2023-05-23 08:52:27 +00:00
class Follows extends PureComponent {
2023-04-23 20:24:53 +00:00
static propTypes = {
onBack : PropTypes . func ,
dispatch : PropTypes . func . isRequired ,
suggestions : ImmutablePropTypes . list ,
account : ImmutablePropTypes . map ,
isLoading : PropTypes . bool ,
2023-05-11 05:55:10 +00:00
multiColumn : PropTypes . bool ,
2023-04-23 20:24:53 +00:00
} ;
componentDidMount ( ) {
const { dispatch } = this . props ;
dispatch ( fetchSuggestions ( true ) ) ;
}
componentWillUnmount ( ) {
const { dispatch } = this . props ;
dispatch ( markAsPartial ( 'home' ) ) ;
}
render ( ) {
2023-05-11 05:55:10 +00:00
const { onBack , isLoading , suggestions , account , multiColumn } = this . props ;
2023-04-23 20:24:53 +00:00
2023-04-25 09:12:37 +00:00
let loadedContent ;
if ( isLoading ) {
loadedContent = ( new Array ( 8 ) ) . fill ( ) . map ( ( _ , i ) => < EmptyAccount key = { i } / > ) ;
} else if ( suggestions . isEmpty ( ) ) {
loadedContent = < div className = 'follow-recommendations__empty' > < FormattedMessage id = 'onboarding.follows.empty' defaultMessage = 'Unfortunately, no results can be shown right now. You can try using search or browsing the explore page to find people to follow, or try again later.' / > < / div > ;
} else {
loadedContent = suggestions . map ( suggestion => < Account id = { suggestion . get ( 'account' ) } key = { suggestion . get ( 'account' ) } / > ) ;
}
2023-04-23 20:24:53 +00:00
return (
< Column >
2023-05-11 05:55:10 +00:00
< ColumnBackButton multiColumn = { multiColumn } onClick = { onBack } / >
2023-04-23 20:24:53 +00:00
< div className = 'scrollable privacy-policy' >
< div className = 'column-title' >
< h3 > < FormattedMessage id = 'onboarding.follows.title' defaultMessage = 'Popular on Mastodon' / > < / h3 >
< p > < FormattedMessage id = 'onboarding.follows.lead' defaultMessage = 'You curate your own home feed. The more people you follow, the more active and interesting it will be. These profiles may be a good starting point—you can always unfollow them later!' / > < / p >
< / div >
< ProgressIndicator steps = { 7 } completed = { account . get ( 'following_count' ) * 1 } / >
< div className = 'follow-recommendations' >
2023-04-25 09:12:37 +00:00
{ loadedContent }
2023-04-23 20:24:53 +00:00
< / div >
2023-04-25 09:12:37 +00:00
< p className = 'onboarding__lead' > < FormattedHTMLMessage id = 'onboarding.tips.accounts_from_other_servers' defaultMessage = '<strong>Did you know?</strong> Since Mastodon is decentralized, some profiles you come across will be hosted on servers other than yours. And yet you can interact with them seamlessly! Their server is in the second half of their username!' / > < / p >
2023-04-23 20:24:53 +00:00
< div className = 'onboarding__footer' >
< button className = 'link-button' onClick = { onBack } > < FormattedMessage id = 'onboarding.actions.back' defaultMessage = 'Take me back' / > < / button >
< / div >
< / div >
< / Column >
) ;
}
}
2023-05-11 05:55:10 +00:00
export default connect ( mapStateToProps ) ( Follows ) ;