You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import PropTypes from 'prop-types';
  4. import StatusListContainer from '../ui/containers/status_list_container';
  5. import Column from '../ui/components/column';
  6. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  7. import ColumnSettingsContainer from './containers/column_settings_container';
  8. import { Link } from 'react-router';
  9. const messages = defineMessages({
  10. title: { id: 'column.home', defaultMessage: 'Home' }
  11. });
  12. const mapStateToProps = state => ({
  13. hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
  14. hasFollows: state.getIn(['accounts_counters', state.getIn(['meta', 'me']), 'following_count']) > 0
  15. });
  16. class HomeTimeline extends React.PureComponent {
  17. static propTypes = {
  18. intl: PropTypes.object.isRequired,
  19. hasUnread: PropTypes.bool,
  20. hasFollows: PropTypes.bool
  21. };
  22. render () {
  23. const { intl, hasUnread, hasFollows } = this.props;
  24. let emptyMessage;
  25. if (hasFollows) {
  26. emptyMessage = <FormattedMessage id='empty_column.home.inactivity' defaultMessage="Your home feed is empty. If you have been inactive for a while, it will be regenerated for you soon." />
  27. } else {
  28. emptyMessage = <FormattedMessage id='empty_column.home' defaultMessage="You aren't following anyone yet. Visit {public} or use search to get started and meet other users." values={{ public: <Link to='/timelines/public'><FormattedMessage id='empty_column.home.public_timeline' defaultMessage='the public timeline' /></Link> }} />;
  29. }
  30. return (
  31. <Column icon='home' active={hasUnread} heading={intl.formatMessage(messages.title)}>
  32. <ColumnSettingsContainer />
  33. <StatusListContainer
  34. {...this.props}
  35. scrollKey='home_timeline'
  36. type='home'
  37. emptyMessage={emptyMessage}
  38. />
  39. </Column>
  40. );
  41. }
  42. }
  43. export default connect(mapStateToProps)(injectIntl(HomeTimeline));