Change featured hashtags to be displayed in navigation panel (#19382)
parent
1b83040bd4
commit
aefa9253d6
9 changed files with 162 additions and 102 deletions
@ -0,0 +1,30 @@ |
||||
import React from 'react'; |
||||
import { Switch, Route, withRouter } from 'react-router-dom'; |
||||
import { showTrends } from 'mastodon/initial_state'; |
||||
import Trends from 'mastodon/features/getting_started/containers/trends_container'; |
||||
import AccountNavigation from 'mastodon/features/account/navigation'; |
||||
|
||||
const DefaultNavigation = () => ( |
||||
<> |
||||
{showTrends && ( |
||||
<> |
||||
<div className='flex-spacer' /> |
||||
<Trends /> |
||||
</> |
||||
)} |
||||
</> |
||||
); |
||||
|
||||
export default @withRouter |
||||
class NavigationPortal extends React.PureComponent { |
||||
|
||||
render () { |
||||
return ( |
||||
<Switch> |
||||
<Route path='/@:acct/(tagged/:tagged?)?' component={AccountNavigation} /> |
||||
<Route component={DefaultNavigation} /> |
||||
</Switch> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
import { connect } from 'react-redux'; |
||||
import FeaturedTags from '../components/featured_tags'; |
||||
import { makeGetAccount } from 'mastodon/selectors'; |
||||
import { List as ImmutableList } from 'immutable'; |
||||
|
||||
const mapStateToProps = () => { |
||||
const getAccount = makeGetAccount(); |
||||
|
||||
return (state, { accountId }) => ({ |
||||
account: getAccount(state, accountId), |
||||
featuredTags: state.getIn(['user_lists', 'featured_tags', accountId, 'items'], ImmutableList()), |
||||
}); |
||||
}; |
||||
|
||||
export default connect(mapStateToProps)(FeaturedTags); |
@ -0,0 +1,51 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import { connect } from 'react-redux'; |
||||
import FeaturedTags from 'mastodon/features/account/containers/featured_tags_container'; |
||||
|
||||
const mapStateToProps = (state, { match: { params: { acct } } }) => { |
||||
const accountId = state.getIn(['accounts_map', acct]); |
||||
|
||||
if (!accountId) { |
||||
return { |
||||
isLoading: true, |
||||
}; |
||||
} |
||||
|
||||
return { |
||||
accountId, |
||||
isLoading: false, |
||||
}; |
||||
}; |
||||
|
||||
export default @connect(mapStateToProps) |
||||
class AccountNavigation extends React.PureComponent { |
||||
|
||||
static propTypes = { |
||||
match: PropTypes.shape({ |
||||
params: PropTypes.shape({ |
||||
acct: PropTypes.string, |
||||
tagged: PropTypes.string, |
||||
}).isRequired, |
||||
}).isRequired, |
||||
|
||||
accountId: PropTypes.string, |
||||
isLoading: PropTypes.bool, |
||||
}; |
||||
|
||||
render () { |
||||
const { accountId, isLoading, match: { params: { tagged } } } = this.props; |
||||
|
||||
if (isLoading) { |
||||
return null; |
||||
} |
||||
|
||||
return ( |
||||
<> |
||||
<div className='flex-spacer' /> |
||||
<FeaturedTags accountId={accountId} tagged={tagged} /> |
||||
</> |
||||
); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue