2024-07-25 17:05:54 +00:00
|
|
|
import { injectIntl } from 'react-intl';
|
2023-05-23 15:15:17 +00:00
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2024-07-25 17:05:54 +00:00
|
|
|
import { openModal } from 'mastodon/actions/modal';
|
|
|
|
|
2016-10-28 18:05:44 +00:00
|
|
|
import {
|
|
|
|
followAccount,
|
2017-01-16 18:36:32 +00:00
|
|
|
blockAccount,
|
2017-02-06 01:51:56 +00:00
|
|
|
unblockAccount,
|
|
|
|
muteAccount,
|
|
|
|
unmuteAccount,
|
2016-11-20 18:39:18 +00:00
|
|
|
} from '../actions/accounts';
|
2017-11-15 02:56:41 +00:00
|
|
|
import { initMuteModal } from '../actions/mutes';
|
2023-05-23 15:15:17 +00:00
|
|
|
import Account from '../components/account';
|
|
|
|
import { makeGetAccount } from '../selectors';
|
2017-07-18 15:14:43 +00:00
|
|
|
|
2016-10-27 19:59:56 +00:00
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getAccount = makeGetAccount();
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
account: getAccount(state, props.id),
|
|
|
|
});
|
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
2024-07-25 17:05:54 +00:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2017-07-18 15:14:43 +00:00
|
|
|
|
2016-10-28 18:05:44 +00:00
|
|
|
onFollow (account) {
|
2017-09-02 18:44:41 +00:00
|
|
|
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
2024-07-25 17:05:54 +00:00
|
|
|
dispatch(openModal({ modalType: 'CONFIRM_UNFOLLOW', modalProps: { account } }));
|
2016-10-28 18:05:44 +00:00
|
|
|
} else {
|
|
|
|
dispatch(followAccount(account.get('id')));
|
|
|
|
}
|
2017-01-16 18:36:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onBlock (account) {
|
|
|
|
if (account.getIn(['relationship', 'blocking'])) {
|
|
|
|
dispatch(unblockAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(blockAccount(account.get('id')));
|
|
|
|
}
|
2017-02-06 01:51:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onMute (account) {
|
|
|
|
if (account.getIn(['relationship', 'muting'])) {
|
|
|
|
dispatch(unmuteAccount(account.get('id')));
|
|
|
|
} else {
|
2017-11-15 02:56:41 +00:00
|
|
|
dispatch(initMuteModal(account));
|
2017-02-06 01:51:56 +00:00
|
|
|
}
|
2017-05-20 15:31:47 +00:00
|
|
|
},
|
2017-07-18 15:14:43 +00:00
|
|
|
|
2017-11-15 02:56:41 +00:00
|
|
|
|
|
|
|
onMuteNotifications (account, notifications) {
|
|
|
|
dispatch(muteAccount(account.get('id'), notifications));
|
|
|
|
},
|
2016-10-27 19:59:56 +00:00
|
|
|
});
|
|
|
|
|
2017-07-18 15:14:43 +00:00
|
|
|
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Account));
|