2017-05-03 09:04:16 +09:00
|
|
|
import React from 'react';
|
2017-01-31 05:40:55 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-22 03:05:35 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2017-11-18 12:11:18 +09:00
|
|
|
import InnerHeader from 'themes/glitch/features/account/components/header';
|
|
|
|
import ActionBar from 'themes/glitch/features/account/components/action_bar';
|
|
|
|
import MissingIndicator from 'themes/glitch/components/missing_indicator';
|
2017-05-03 09:04:16 +09:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-06-24 02:36:54 +09:00
|
|
|
export default class Header extends ImmutablePureComponent {
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
static propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
onFollow: PropTypes.func.isRequired,
|
|
|
|
onBlock: PropTypes.func.isRequired,
|
|
|
|
onMention: PropTypes.func.isRequired,
|
2017-11-09 23:41:10 +09:00
|
|
|
onReblogToggle: PropTypes.func.isRequired,
|
2017-05-12 21:44:10 +09:00
|
|
|
onReport: PropTypes.func.isRequired,
|
2017-05-20 04:05:32 +09:00
|
|
|
onMute: PropTypes.func.isRequired,
|
|
|
|
onBlockDomain: PropTypes.func.isRequired,
|
|
|
|
onUnblockDomain: PropTypes.func.isRequired,
|
2017-05-12 21:44:10 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
static contextTypes = {
|
2017-05-21 00:31:47 +09:00
|
|
|
router: PropTypes.object,
|
2017-05-12 21:44:10 +09:00
|
|
|
};
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
handleFollow = () => {
|
2017-01-31 05:40:55 +09:00
|
|
|
this.props.onFollow(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
handleBlock = () => {
|
2017-01-31 05:40:55 +09:00
|
|
|
this.props.onBlock(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
handleMention = () => {
|
2017-06-21 03:40:03 +09:00
|
|
|
this.props.onMention(this.props.account, this.context.router.history);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
handleReport = () => {
|
2017-02-15 04:59:26 +09:00
|
|
|
this.props.onReport(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-02-15 04:59:26 +09:00
|
|
|
|
2017-11-09 23:41:10 +09:00
|
|
|
handleReblogToggle = () => {
|
|
|
|
this.props.onReblogToggle(this.props.account);
|
|
|
|
}
|
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
handleMute = () => {
|
2017-02-06 10:51:56 +09:00
|
|
|
this.props.onMute(this.props.account);
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2017-02-06 10:51:56 +09:00
|
|
|
|
2017-05-20 04:05:32 +09:00
|
|
|
handleBlockDomain = () => {
|
|
|
|
const domain = this.props.account.get('acct').split('@')[1];
|
|
|
|
|
|
|
|
if (!domain) return;
|
|
|
|
|
|
|
|
this.props.onBlockDomain(domain, this.props.account.get('id'));
|
|
|
|
}
|
|
|
|
|
|
|
|
handleUnblockDomain = () => {
|
|
|
|
const domain = this.props.account.get('acct').split('@')[1];
|
|
|
|
|
|
|
|
if (!domain) return;
|
|
|
|
|
|
|
|
this.props.onUnblockDomain(domain, this.props.account.get('id'));
|
|
|
|
}
|
|
|
|
|
2017-01-31 05:40:55 +09:00
|
|
|
render () {
|
2017-10-31 11:27:48 +09:00
|
|
|
const { account } = this.props;
|
2017-01-31 05:40:55 +09:00
|
|
|
|
2017-02-27 07:06:27 +09:00
|
|
|
if (account === null) {
|
|
|
|
return <MissingIndicator />;
|
2017-01-31 05:40:55 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2017-04-23 11:26:55 +09:00
|
|
|
<div className='account-timeline__header'>
|
2017-01-31 05:40:55 +09:00
|
|
|
<InnerHeader
|
|
|
|
account={account}
|
|
|
|
onFollow={this.handleFollow}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<ActionBar
|
|
|
|
account={account}
|
|
|
|
onBlock={this.handleBlock}
|
|
|
|
onMention={this.handleMention}
|
2017-11-09 23:41:10 +09:00
|
|
|
onReblogToggle={this.handleReblogToggle}
|
2017-02-15 04:59:26 +09:00
|
|
|
onReport={this.handleReport}
|
2017-02-06 10:51:56 +09:00
|
|
|
onMute={this.handleMute}
|
2017-05-20 04:05:32 +09:00
|
|
|
onBlockDomain={this.handleBlockDomain}
|
|
|
|
onUnblockDomain={this.handleUnblockDomain}
|
2017-01-31 05:40:55 +09:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-04-22 03:05:35 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
}
|