From f21e7d6ac06556671c2663ce2879442c60230b32 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 30 Jan 2017 21:40:55 +0100 Subject: Make profile header scroll along with contents. AccountTimeline, Followers and Following are no longer nested inside a common parent (), instead they all embed --- .../containers/header_container.jsx | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx (limited to 'app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx') diff --git a/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx b/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx new file mode 100644 index 000000000..dca826596 --- /dev/null +++ b/app/assets/javascripts/components/features/account_timeline/containers/header_container.jsx @@ -0,0 +1,45 @@ +import { connect } from 'react-redux'; +import { makeGetAccount } from '../../../selectors'; +import Header from '../components/header'; +import { + followAccount, + unfollowAccount, + blockAccount, + unblockAccount +} from '../../../actions/accounts'; +import { mentionCompose } from '../../../actions/compose'; + +const makeMapStateToProps = () => { + const getAccount = makeGetAccount(); + + const mapStateToProps = (state, { accountId }) => ({ + account: getAccount(state, Number(accountId)), + me: state.getIn(['meta', 'me']) + }); + + return mapStateToProps; +}; + +const mapDispatchToProps = dispatch => ({ + onFollow (account) { + if (account.getIn(['relationship', 'following'])) { + dispatch(unfollowAccount(account.get('id'))); + } else { + dispatch(followAccount(account.get('id'))); + } + }, + + onBlock (account) { + if (account.getIn(['relationship', 'blocking'])) { + dispatch(unblockAccount(account.get('id'))); + } else { + dispatch(blockAccount(account.get('id'))); + } + }, + + onMention (account, router) { + dispatch(mentionCompose(account, router)); + } +}); + +export default connect(makeMapStateToProps, mapDispatchToProps)(Header); -- cgit