2016-11-21 03:39:18 +09:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { makeGetAccount } from '../selectors';
|
|
|
|
import Account from '../components/account';
|
2016-10-29 03:05:44 +09:00
|
|
|
import {
|
|
|
|
followAccount,
|
2017-01-17 03:36:32 +09:00
|
|
|
unfollowAccount,
|
|
|
|
blockAccount,
|
2017-02-06 10:51:56 +09:00
|
|
|
unblockAccount,
|
|
|
|
muteAccount,
|
|
|
|
unmuteAccount,
|
2016-11-21 03:39:18 +09:00
|
|
|
} from '../actions/accounts';
|
2016-10-28 04:59:56 +09:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getAccount = makeGetAccount();
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
account: getAccount(state, props.id),
|
2017-05-21 00:31:47 +09:00
|
|
|
me: state.getIn(['meta', 'me']),
|
2016-10-28 04:59:56 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2016-10-29 03:05:44 +09:00
|
|
|
onFollow (account) {
|
|
|
|
if (account.getIn(['relationship', 'following'])) {
|
|
|
|
dispatch(unfollowAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(followAccount(account.get('id')));
|
|
|
|
}
|
2017-01-17 03:36:32 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
onBlock (account) {
|
|
|
|
if (account.getIn(['relationship', 'blocking'])) {
|
|
|
|
dispatch(unblockAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(blockAccount(account.get('id')));
|
|
|
|
}
|
2017-02-06 10:51:56 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
onMute (account) {
|
|
|
|
if (account.getIn(['relationship', 'muting'])) {
|
|
|
|
dispatch(unmuteAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(muteAccount(account.get('id')));
|
|
|
|
}
|
2017-05-21 00:31:47 +09:00
|
|
|
},
|
2016-10-28 04:59:56 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Account);
|