Updated pages, layout component structures

• Updated:
- pages, layout component structures
This commit is contained in:
mgabdev
2020-08-14 12:45:59 -05:00
parent 67e1082cf5
commit 014e476b5d
23 changed files with 461 additions and 500 deletions

View File

@@ -9,46 +9,10 @@ import ColumnIndicator from '../components/column_indicator'
import Block from '../components/block'
import ProfileLayout from '../layouts/profile_layout'
const mapStateToProps = (state, { params: { username } }) => {
const accounts = state.getIn(['accounts'])
const account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase())
const accountId = !!account ? account.get('id') : -1
const isBlocked = state.getIn(['relationships', accountId, 'blocked_by'], false)
const isLocked = state.getIn(['accounts', accountId, 'locked'], false)
const isFollowing = state.getIn(['relationships', accountId, 'following'], false)
const unavailable = (me === accountId) ? false : (isBlocked || (isLocked && !isFollowing))
const getAccount = makeGetAccount()
return {
unavailable,
account: accountId !== -1 ? getAccount(state, accountId) : null,
}
}
const mapDispatchToProps = (dispatch) => ({
onFetchAccountByUsername(username) {
dispatch(fetchAccountByUsername(username))
},
})
export default
@connect(mapStateToProps, mapDispatchToProps)
class ProfilePage extends ImmutablePureComponent {
static propTypes = {
children: PropTypes.node,
params: PropTypes.object.isRequired,
account: ImmutablePropTypes.map,
onFetchAccountByUsername: PropTypes.func.isRequired,
unavailable: PropTypes.bool.isRequired,
noSidebar: PropTypes.bool,
}
componentDidMount() {
this.props.onFetchAccountByUsername(this.props.params.username)
this.props.dispatch(fetchAccountByUsername(this.props.params.username))
}
render() {
@@ -89,4 +53,34 @@ class ProfilePage extends ImmutablePureComponent {
)
}
}
}
const mapStateToProps = (state, { params: { username } }) => {
const accounts = state.getIn(['accounts'])
const account = accounts.find(acct => username.toLowerCase() === acct.getIn(['acct'], '').toLowerCase())
const accountId = !!account ? account.get('id') : -1
const isBlocked = state.getIn(['relationships', accountId, 'blocked_by'], false)
const isLocked = state.getIn(['accounts', accountId, 'locked'], false)
const isFollowing = state.getIn(['relationships', accountId, 'following'], false)
const unavailable = (me === accountId) ? false : (isBlocked || (isLocked && !isFollowing))
const getAccount = makeGetAccount()
return {
unavailable,
account: accountId !== -1 ? getAccount(state, accountId) : null,
}
}
ProfilePage.propTypes = {
account: ImmutablePropTypes.map,
children: PropTypes.node,
dispatch: PropTypes.func.isRequired,
noSidebar: PropTypes.bool,
params: PropTypes.object.isRequired,
unavailable: PropTypes.bool.isRequired,
}
export default connect(mapStateToProps)(ProfilePage)