diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2020-06-14 22:29:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-14 22:29:40 +0200 |
commit | 3e9dc4044bb7e1ef6131fbd6430ed85b3cc2fcfa (patch) | |
tree | deea7444dfd0052cb99d6a5b6f42796fbef52194 /app/javascript/mastodon/features/following/index.js | |
parent | b1484cf3ceebe1f1f083e4c06872493dc0a68511 (diff) |
Add hints about incomplete remote content to web UI (#14031)
Diffstat (limited to 'app/javascript/mastodon/features/following/index.js')
-rw-r--r-- | app/javascript/mastodon/features/following/index.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/app/javascript/mastodon/features/following/index.js b/app/javascript/mastodon/features/following/index.js index 06311bbdc..2d2ed7be4 100644 --- a/app/javascript/mastodon/features/following/index.js +++ b/app/javascript/mastodon/features/following/index.js @@ -17,8 +17,11 @@ import HeaderContainer from '../account_timeline/containers/header_container'; import ColumnBackButton from '../../components/column_back_button'; import ScrollableList from '../../components/scrollable_list'; import MissingIndicator from 'mastodon/components/missing_indicator'; +import TimelineHint from 'mastodon/components/timeline_hint'; const mapStateToProps = (state, props) => ({ + remote: !!state.getIn(['accounts', props.params.accountId, 'acct']) !== state.getIn(['accounts', props.params.accountId, 'username']), + remoteUrl: state.getIn(['accounts', props.params.accountId, 'url']), isAccount: !!state.getIn(['accounts', props.params.accountId]), accountIds: state.getIn(['user_lists', 'following', props.params.accountId, 'items']), hasMore: !!state.getIn(['user_lists', 'following', props.params.accountId, 'next']), @@ -26,6 +29,14 @@ const mapStateToProps = (state, props) => ({ blockedBy: state.getIn(['relationships', props.params.accountId, 'blocked_by'], false), }); +const RemoteHint = ({ url }) => ( + <TimelineHint url={url} resource={<FormattedMessage id='timeline_hint.resources.follows' defaultMessage='Follows' />} /> +); + +RemoteHint.propTypes = { + url: PropTypes.string.isRequired, +}; + export default @connect(mapStateToProps) class Following extends ImmutablePureComponent { @@ -38,6 +49,8 @@ class Following extends ImmutablePureComponent { isLoading: PropTypes.bool, blockedBy: PropTypes.bool, isAccount: PropTypes.bool, + remote: PropTypes.bool, + remoteUrl: PropTypes.string, multiColumn: PropTypes.bool, }; @@ -60,7 +73,7 @@ class Following extends ImmutablePureComponent { }, 300, { leading: true }); render () { - const { shouldUpdateScroll, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading } = this.props; + const { shouldUpdateScroll, accountIds, hasMore, blockedBy, isAccount, multiColumn, isLoading, remote, remoteUrl } = this.props; if (!isAccount) { return ( @@ -78,7 +91,17 @@ class Following extends ImmutablePureComponent { ); } - const emptyMessage = blockedBy ? <FormattedMessage id='empty_column.account_unavailable' defaultMessage='Profile unavailable' /> : <FormattedMessage id='account.follows.empty' defaultMessage="This user doesn't follow anyone yet." />; + let emptyMessage; + + if (blockedBy) { + emptyMessage = <FormattedMessage id='empty_column.account_unavailable' defaultMessage='Profile unavailable' />; + } else if (remote && accountIds.isEmpty()) { + emptyMessage = <RemoteHint url={remoteUrl} />; + } else { + emptyMessage = <FormattedMessage id='account.follows.empty' defaultMessage="This user doesn't follow anyone yet." />; + } + + const remoteMessage = remote ? <RemoteHint url={remoteUrl} /> : null; return ( <Column> @@ -92,6 +115,7 @@ class Following extends ImmutablePureComponent { shouldUpdateScroll={shouldUpdateScroll} prepend={<HeaderContainer accountId={this.props.params.accountId} hideTabs />} alwaysPrepend + append={remoteMessage} emptyMessage={emptyMessage} bindToDocument={!multiColumn} > |