Port aefa9253d6
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
local
parent
2cea6e5564
commit
7bb1b917b2
8 changed files with 148 additions and 65 deletions
@ -0,0 +1,30 @@ |
|||||||
|
import React from 'react'; |
||||||
|
import { Switch, Route, withRouter } from 'react-router-dom'; |
||||||
|
import { showTrends } from 'flavours/glitch/initial_state'; |
||||||
|
import Trends from 'flavours/glitch/features/getting_started/containers/trends_container'; |
||||||
|
import AccountNavigation from 'flavours/glitch/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 'flavours/glitch/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 'flavours/glitch/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