1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/app/assets/javascripts/components/features/account/components/action_bar.jsx
Eugen Rochko 3f9708edc4 Change output of api/accounts/:id/follow and unfollow to return relationship
Track relationship in redux state. Display follow/unfollow and following-back
information on account view (unstyled)
2016-09-23 20:23:26 +02:00

48 lines
1.2 KiB
JavaScript

import PureRenderMixin from 'react-addons-pure-render-mixin';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Button from '../../../components/button';
const ActionBar = React.createClass({
propTypes: {
account: ImmutablePropTypes.map.isRequired,
me: React.PropTypes.number.isRequired,
onFollow: React.PropTypes.func.isRequired,
onUnfollow: React.PropTypes.func.isRequired
},
mixins: [PureRenderMixin],
render () {
const { account, me } = this.props;
let followBack = '';
let actionButton = '';
if (account.get('id') === me) {
actionButton = 'This is you!';
} else {
if (account.getIn(['relationship', 'following'])) {
actionButton = <Button text='Unfollow' onClick={this.props.onUnfollow} />
} else {
actionButton = <Button text='Follow' onClick={this.props.onFollow} />
}
if (account.getIn(['relationship', 'followed_by'])) {
followBack = 'follows you';
}
}
return (
<div>
{actionButton}
{account.get('followers_count')} followers
{account.get('following_count')} following
{followBack}
</div>
);
},
});
export default ActionBar;